mirror of
https://github.com/troglobit/editline.git
synced 2025-05-06 04:21:24 +08:00
Minor cleanup
This commit is contained in:
parent
a848011073
commit
d4aa5ac293
@ -33,39 +33,44 @@
|
|||||||
#include "editline.h"
|
#include "editline.h"
|
||||||
|
|
||||||
#ifndef HAVE_PERROR
|
#ifndef HAVE_PERROR
|
||||||
|
extern int errno;
|
||||||
void perror(char *s)
|
void perror(char *s)
|
||||||
{
|
{
|
||||||
extern int errno;
|
fprintf(stderr, "%s: error %d\n", s, errno);
|
||||||
|
|
||||||
(void)fprintf(stderr, "%s: error %d\n", s, errno);
|
|
||||||
}
|
}
|
||||||
#endif /* !HAVE_PERROR */
|
#endif /* !HAVE_PERROR */
|
||||||
|
|
||||||
int main(int argc, char *argv[] __attribute__ ((unused)))
|
int main(int argc, char *argv[] __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
char *prompt;
|
int doit;
|
||||||
char *p;
|
char *prompt, *p;
|
||||||
int doit;
|
|
||||||
|
|
||||||
doit = argc == 1;
|
doit = argc == 1;
|
||||||
if ((prompt = getenv("TESTPROMPT")) == NULL)
|
if ((prompt = getenv("TESTPROMPT")) == NULL)
|
||||||
prompt = "testit> ";
|
prompt = "testit> ";
|
||||||
|
|
||||||
while ((p = readline(prompt)) != NULL) {
|
while ((p = readline(prompt)) != NULL) {
|
||||||
(void)printf("\t\t\t|%s|\n", p);
|
printf("\t\t\t|%s|\n", p);
|
||||||
if (doit) {
|
if (doit) {
|
||||||
if (strncmp(p, "cd ", 3) == 0) {
|
if (strncmp(p, "cd ", 3) == 0) {
|
||||||
if (chdir(&p[3]) < 0) {
|
if (chdir(&p[3]) < 0)
|
||||||
perror(&p[3]);
|
perror(&p[3]);
|
||||||
}
|
} else if (system(p) != 0) {
|
||||||
}
|
|
||||||
else if (system(p) != 0) {
|
|
||||||
perror(p);
|
perror(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_history(p);
|
add_history(p);
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Local Variables:
|
||||||
|
* version-control: t
|
||||||
|
* indent-tabs-mode: t
|
||||||
|
* c-file-style: "ellemtel"
|
||||||
|
* c-basic-offset: 4
|
||||||
|
* End:
|
||||||
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user