1 /* Copyright (C) 1987-2002 Free Software Foundation, Inc.
3 This file is part of the GNU Readline Library, a library for
4 reading lines of text with interactive input and history editing.
6 The GNU Readline Library is free software; you can redistribute it
7 and/or modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2, or
9 (at your option) any later version.
11 The GNU Readline Library is distributed in the hope that it will be
12 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 The GNU General Public License is often shipped with GNU software, and
17 is generally kept in a file called COPYING or LICENSE. If you do not
18 have a copy of the license, write to the Free Software Foundation,
19 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
23 #ifdef READLINE_LIBRARY
26 # include <readline/history.h>
46 t
= fgets (line
, sizeof (line
) - 1, stdin
);
50 if (t
[len
- 1] == '\n')
55 strcpy (line
, "quit");
64 result
= history_expand (line
, &expansion
);
66 fprintf (stderr
, "%s\n", expansion
);
68 if (result
< 0 || result
== 2)
74 add_history (expansion
);
75 strncpy (line
, expansion
, sizeof (line
) - 1);
79 if (strcmp (line
, "quit") == 0)
81 else if (strcmp (line
, "save") == 0)
82 write_history ("history_file");
83 else if (strcmp (line
, "read") == 0)
84 read_history ("history_file");
85 else if (strcmp (line
, "list") == 0)
87 register HIST_ENTRY
**the_list
;
92 the_list
= history_list ();
94 for (i
= 0; the_list
[i
]; i
++)
96 tt
= history_get_time (the_list
[i
]);
98 strftime (timestr
, sizeof (timestr
), "%a %R", localtime(&tt
));
100 strcpy (timestr
, "??");
101 printf ("%d: %s: %s\n", i
+ history_base
, timestr
, the_list
[i
]->line
);
104 else if (strncmp (line
, "delete", 6) == 0)
107 if ((sscanf (line
+ 6, "%d", &which
)) == 1)
109 HIST_ENTRY
*entry
= remove_history (which
);
111 fprintf (stderr
, "No such entry %d\n", which
);
120 fprintf (stderr
, "non-numeric arg given to `delete'\n");
This page took 0.03166 seconds and 4 git commands to generate.