mirror of
https://github.com/troglobit/editline.git
synced 2025-09-18 19:10:09 +08:00
Merge branch 'master' into readline-compat-for-fileman
This commit is contained in:
@@ -84,11 +84,11 @@ int main(int ac __attribute__ ((unused)), char *av[] __attribute__ ((unused)))
|
||||
char *prompt = "cli> ";
|
||||
|
||||
/* Setup callbacks */
|
||||
rl_complete = &my_rl_complete;
|
||||
rl_list_possib = &my_rl_list_possib;
|
||||
rl_set_complete_func(&my_rl_complete);
|
||||
rl_set_list_possib_func(&my_rl_list_possib);
|
||||
|
||||
while ((line = readline(prompt)) != NULL) {
|
||||
(void)printf("\t\t\t|%s|\n", line);
|
||||
printf("\t\t\t|%s|\n", line);
|
||||
free(line);
|
||||
}
|
||||
|
||||
|
@@ -33,39 +33,44 @@
|
||||
#include "editline.h"
|
||||
|
||||
#ifndef HAVE_PERROR
|
||||
extern int errno;
|
||||
void perror(char *s)
|
||||
{
|
||||
extern int errno;
|
||||
|
||||
(void)fprintf(stderr, "%s: error %d\n", s, errno);
|
||||
fprintf(stderr, "%s: error %d\n", s, errno);
|
||||
}
|
||||
#endif /* !HAVE_PERROR */
|
||||
|
||||
int main(int argc, char *argv[] __attribute__ ((unused)))
|
||||
{
|
||||
char *prompt;
|
||||
char *p;
|
||||
int doit;
|
||||
int doit;
|
||||
char *prompt, *p;
|
||||
|
||||
doit = argc == 1;
|
||||
if ((prompt = getenv("TESTPROMPT")) == NULL)
|
||||
prompt = "testit> ";
|
||||
prompt = "testit> ";
|
||||
|
||||
while ((p = readline(prompt)) != NULL) {
|
||||
(void)printf("\t\t\t|%s|\n", p);
|
||||
printf("\t\t\t|%s|\n", p);
|
||||
if (doit) {
|
||||
if (strncmp(p, "cd ", 3) == 0) {
|
||||
if (chdir(&p[3]) < 0) {
|
||||
if (chdir(&p[3]) < 0)
|
||||
perror(&p[3]);
|
||||
}
|
||||
}
|
||||
else if (system(p) != 0) {
|
||||
} else if (system(p) != 0) {
|
||||
perror(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
add_history(p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* version-control: t
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "ellemtel"
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
|
Reference in New Issue
Block a user