13 t = fgets (line, sizeof (line) - 1, stdin);
17 if (t[len - 1] == '\n')
22 strcpy (line, "quit");
31 result = history_expand (line, &expansion);
33 fprintf (stderr, "%s\n", expansion);
35 if (result < 0 || result == 2)
41 add_history (expansion);
42 strncpy (line, expansion, sizeof (line) - 1);
46 if (strcmp (line, "quit") == 0)
48 else if (strcmp (line, "save") == 0)
49 write_history ("history_file");
50 else if (strcmp (line, "read") == 0)
51 read_history ("history_file");
52 else if (strcmp (line, "list") == 0)
54 register HIST_ENTRY **the_list;
57 the_list = history_list ();
59 for (i = 0; the_list[i]; i++)
60 printf ("%d: %s\n", i + history_base, the_list[i]->line);
62 else if (strncmp (line, "delete", 6) == 0)
65 if ((sscanf (line + 6, "%d", &which)) == 1)
67 HIST_ENTRY *entry = remove_history (which);
69 fprintf (stderr, "No such entry %d\n", which);
78 fprintf (stderr, "non-numeric arg given to `delete'\n");