3 #ifdef READLINE_LIBRARY
6 # include <readline/history.h>
23 t = fgets (line, sizeof (line) - 1, stdin);
27 if (t[len - 1] == '\n')
32 strcpy (line, "quit");
41 result = history_expand (line, &expansion);
43 fprintf (stderr, "%s\n", expansion);
45 if (result < 0 || result == 2)
51 add_history (expansion);
52 strncpy (line, expansion, sizeof (line) - 1);
56 if (strcmp (line, "quit") == 0)
58 else if (strcmp (line, "save") == 0)
59 write_history ("history_file");
60 else if (strcmp (line, "read") == 0)
61 read_history ("history_file");
62 else if (strcmp (line, "list") == 0)
64 register HIST_ENTRY **the_list;
67 the_list = history_list ();
69 for (i = 0; the_list[i]; i++)
70 printf ("%d: %s\n", i + history_base, the_list[i]->line);
72 else if (strncmp (line, "delete", 6) == 0)
75 if ((sscanf (line + 6, "%d", &which)) == 1)
77 HIST_ENTRY *entry = remove_history (which);
79 fprintf (stderr, "No such entry %d\n", which);
88 fprintf (stderr, "non-numeric arg given to `delete'\n");