From: "Rocky Bernstein" <rocky.bernstein@gmail.com>
To: "Peter Stephenson" <pws@csr.com>
Cc: "Zsh hackers list" <zsh-workers@sunsite.dk>
Subject: Re: fc (history) requires zsh is interactive? Why can't interactive toggled?
Date: Mon, 22 Sep 2008 23:31:51 -0400 [thread overview]
Message-ID: <6cd6de210809222031n12743897l3e4474593a9a780a@mail.gmail.com> (raw)
In-Reply-To: <200809221425.m8MEPcWg015191@news01.csr.com>
[-- Attachment #1: Type: text/plain, Size: 2834 bytes --]
I removed the interact test and played around with fc and don't see
any difference.
The current regression tests which all work fine.
So here's a suggestion that I believe will have little impact on zsh developers.
Attached should be a two-line patch to #ifdef this code out. Apply it.
If people find problems in fc as a result of this change, I'll fix
these. If we get to a release and people for whatever reason feel the
that life was better disallowing fc unless in interactive mode, then
it is a matter of deleting two lines and you have the old behavior.
I will also remove the interactive flag on zshdb as another means of
getting test coverage there with a program that uses fc without
interactive mode set.
And to show good faith in fixing whatever bugs come up, attached is a
test in an new "fc" file for the bug I recently discovered which by
the way has nothing to do with whether or not interactive is set.
On Mon, Sep 22, 2008 at 10:25 AM, Peter Stephenson <pws@csr.com> wrote:
> "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@csr.com> Software Engineer
> CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
> Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fc.patch --]
[-- Type: text/x-diff; name=fc.patch, Size: 602 bytes --]
? Test/B06fc.ztst
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.207
diff -u -r1.207 builtin.c
--- Src/builtin.c 15 Sep 2008 08:57:27 -0000 1.207
+++ Src/builtin.c 23 Sep 2008 03:17:42 -0000
@@ -1296,10 +1296,12 @@
Patprog pprog = NULL;
/* fc is only permitted in interactive shells */
+#ifdef FACIST_INTERACTIVE
if (!interact) {
zwarnnam(nam, "not interactive shell");
return 1;
}
+#endif
if (OPT_ISSET(ops,'p')) {
char *hf = "";
zlong hs = DEFAULT_HISTSIZE;
[-- Attachment #3: B06fc.ztst --]
[-- Type: application/octet-stream, Size: 215 bytes --]
# Tests of fc command
%prep
mkdir fc.tmp
cd fc.tmp
print 'fc -l foo' >fcl
%test
$ZTST_testdir/../Src/zsh ./fcl
1:Checking that fc -l foo doesn't core dump history is empty
?./fcl:fc:1: event not found: foo
next prev parent reply other threads:[~2008-09-23 3:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-22 0:37 Rocky Bernstein
2008-09-22 12:06 ` Peter Stephenson
2008-09-22 13:58 ` Rocky Bernstein
2008-09-22 14:25 ` Peter Stephenson
2008-09-23 3:31 ` Rocky Bernstein [this message]
2008-09-23 8:42 ` Peter Stephenson
2008-09-23 18:02 ` Rocky Bernstein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6cd6de210809222031n12743897l3e4474593a9a780a@mail.gmail.com \
--to=rocky.bernstein@gmail.com \
--cc=pws@csr.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).