1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-27 04:40:59 +01:00

30469: Src/builtin.c: allow reverse listing of history using

fc -r, but don't allow reverse execution of commands at all.
This commit is contained in:
Peter Stephenson 2012-05-08 11:29:32 +00:00
parent bd95e7658f
commit d60de3001b
2 changed files with 14 additions and 6 deletions

View file

@ -1498,7 +1498,7 @@ bin_fc(char *nam, char **argv, Options ops, int func)
}
if (OPT_ISSET(ops,'l')) {
/* list the required part of the history */
retval = fclist(stdout, ops, first, last, asgf, pprog);
retval = fclist(stdout, ops, first, last, asgf, pprog, 0);
unqueue_signals();
}
else {
@ -1530,7 +1530,7 @@ bin_fc(char *nam, char **argv, Options ops, int func)
}
}
ops->ind['n'] = 1; /* No line numbers here. */
if (!fclist(out, ops, first, last, asgf, pprog)) {
if (!fclist(out, ops, first, last, asgf, pprog, 1)) {
char *editor;
if (func == BIN_R)
@ -1639,7 +1639,7 @@ fcsubs(char **sp, struct asgment *sub)
/**/
static int
fclist(FILE *f, Options ops, zlong first, zlong last,
struct asgment *subs, Patprog pprog)
struct asgment *subs, Patprog pprog, int is_command)
{
int fclistdone = 0;
zlong tmp;
@ -1652,8 +1652,8 @@ fclist(FILE *f, Options ops, zlong first, zlong last,
last = first;
first = tmp;
}
if (first > last) {
zwarnnam("fc", "history events are in wrong order, aborted");
if (is_command && first > last) {
zwarnnam("fc", "history events can't be executed backwards, aborted");
if (f != stdout)
fclose(f);
return 1;