Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: fc (history) requires zsh is interactive? Why can't interactive toggled?



"Rocky Bernstein" wrote:
> > So "fc -l"
> > hasn't been very useful and the error message tends to be more helpful than
> > simply doing nothing because you're in a non-interactive shell with, the
> > vast majority of the time, no history.
> 
> The problem is that an error message which prevents functioning of a
> command should only be given when there *is* an error, not in
> anticipation of a situation which sometimes is an error.

Granted that's a perfectly good general rule, but it's not, in this
case, the "real" problem, which, as I've said many times, is that we
simply don't have anything remotely like the effort to implement all
these entirely reasonable things, never did, and probably never shall.
Many errors are simply there because the general case was much more
difficult than making it work the vast majority of the time.

>> There's no basic reason why it
>> shouldn't work if history works elsewhere.
>
>> Could this be changed please?

As you appear to have some test cases, could you please try removing the
lines in builtin.c:bin_fc() that say

    /* fc is only permitted in interactive shells */
    if (!interact) {
	zwarnnam(nam, "not interactive shell");
	return 1;
    }

and seeing what happens?  I suspect some options really don't work in
this case, but without trying it's hard to tell what they are.  If we're
lucky, it may just be we need to catch a few extra test case lower down
like the one you picked up in up_histent().  Otherwise, it'll have to go
on the queue of things I might get around to one day.

Thanks.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



Messages sorted by: Reverse Date, Date, Thread, Author