From: Alexandre Duret-Lutz <duret_g@epita.fr>
To: "Bart Schaefer" <schaefer@candle.brasslantern.com>
Cc: Alexandre Duret-Lutz <duret_g@epita.fr>, zsh-workers@math.gatech.edu
Subject: Re: *suggestion* for NULLCMD and emulate [ck]sh
Date: 08 Feb 2000 23:42:15 +0100 [thread overview]
Message-ID: <mvb7lgfgvug.fsf@phobos.lrde.epita.fr> (raw)
In-Reply-To: "Bart Schaefer"'s message of "Tue, 8 Feb 2000 18:07:00 +0000"
>>> "Bart" == Bart Schaefer <schaefer@candle.brasslantern.com> writes:
[...]
Bart> Rather than have zsh change the value of NULLCMD when it starts up
Bart> as sh or ksh, the proposed SH_NULLCMD option should cause the ": >
Bart> file" style to be used regardless of the value of NULLCMD.
Bart> The second option, which I'd call CSH_NULLCMD for consistency, would
Bart> also ignore the value of NULLCMD but give the "redirection with no
Bart> command" error.
Good, I find this a lot cleaner.
Bart> We then pick one of these to "win" when both are set, as presently
Bart> happens with e.g. NULLGLOB and CSH_NULLGLOB. I don't really care
Bart> which one wins.
Bart> Do we need something similar for READNULLCMD? Can these same two
Bart> options be overloaded for both at once? If the answers are "yes"
Bart> and "no" then I think the right thing is to not change it at all, as
Bart> it's just too sloppy to get it right. If the first is "no" or the
Bart> second is "yes," go ahead.
You would answer 1:no, 2:yes. I think there is no point trying to emulate
for instance sh for input and csh for ouput. And should you really want to
do this, you could unset both {,C}SH_NULLCMD and play with the
{,READ}NULLCMD parameters as before.
Adapted patch that supersede 9617 below.
Index: Src/zsh.h
--- Src/zsh.h Thu, 03 Feb 2000 00:03:47 +0100 Alexandre
+++ Src/zsh.h Tue, 08 Feb 2000 22:43:05 +0100 Alexandre
@@ -1269,6 +1269,7 @@
CSHJUNKIEHISTORY,
CSHJUNKIELOOPS,
CSHJUNKIEQUOTES,
+ CSHNULLCMD,
CSHNULLGLOB,
EQUALS,
ERREXIT,
@@ -1352,6 +1353,7 @@
SHFILEEXPANSION,
SHGLOB,
SHINSTDIN,
+ SHNULLCMD,
SHOPTIONLETTERS,
SHORTLOOPS,
SHWORDSPLIT,
Index: Src/options.c
--- Src/options.c Fri, 31 Dec 1999 13:32:44 +0100 Alexandre
+++ Src/options.c Tue, 08 Feb 2000 22:43:58 +0100 Alexandre
@@ -102,6 +102,7 @@
{NULL, "cshjunkiehistory", OPT_EMULATE|OPT_CSH, CSHJUNKIEHISTORY},
{NULL, "cshjunkieloops", OPT_EMULATE|OPT_CSH, CSHJUNKIELOOPS},
{NULL, "cshjunkiequotes", OPT_EMULATE|OPT_CSH, CSHJUNKIEQUOTES},
+{NULL, "cshnullcmd", OPT_EMULATE|OPT_CSH, CSHNULLCMD},
{NULL, "cshnullglob", OPT_EMULATE|OPT_CSH, CSHNULLGLOB},
{NULL, "equals", OPT_EMULATE|OPT_ZSH, EQUALS},
{NULL, "errexit", OPT_EMULATE, ERREXIT},
@@ -185,6 +186,7 @@
{NULL, "shfileexpansion", OPT_EMULATE|OPT_BOURNE, SHFILEEXPANSION},
{NULL, "shglob", OPT_EMULATE|OPT_BOURNE, SHGLOB},
{NULL, "shinstdin", OPT_SPECIAL, SHINSTDIN},
+{NULL, "shnullcmd", OPT_EMULATE|OPT_BOURNE, SHNULLCMD},
{NULL, "shoptionletters", OPT_EMULATE|OPT_BOURNE, SHOPTIONLETTERS},
{NULL, "shortloops", OPT_EMULATE|OPT_NONBOURNE, SHORTLOOPS},
{NULL, "shwordsplit", OPT_EMULATE|OPT_BOURNE, SHWORDSPLIT},
Index: Src/init.c
--- Src/init.c Mon, 07 Feb 2000 17:48:28 +0100 Alexandre
+++ Src/init.c Tue, 08 Feb 2000 22:41:05 +0100 Alexandre
@@ -666,17 +666,8 @@
mypid = (zlong) getpid();
term = ztrdup("");
- /* The following variable assignments cause zsh to behave more *
- * like Bourne and Korn shells when invoked as "sh" or "ksh". *
- * NULLCMD=":" and READNULLCMD=":" */
-
- if (emulation == EMULATE_KSH || emulation == EMULATE_SH) {
- nullcmd = ztrdup(":");
- readnullcmd = ztrdup(":");
- } else {
- nullcmd = ztrdup("cat");
- readnullcmd = ztrdup("more");
- }
+ nullcmd = ztrdup("cat");
+ readnullcmd = ztrdup("more");
/* We cache the uid so we know when to *
* recheck the info for `USERNAME' */
Index: Src/exec.c
--- Src/exec.c Tue, 08 Feb 2000 10:59:23 +0100 Alexandre
+++ Src/exec.c Tue, 08 Feb 2000 22:46:41 +0100 Alexandre
@@ -1661,11 +1661,15 @@
} else if (varspc) {
nullexec = 2;
break;
- } else if (!nullcmd || !*nullcmd ||
+ } else if (!nullcmd || !*nullcmd || opts[CSHNULLCMD] ||
(cflags & BINF_PREFIX)) {
zerr("redirection with no command", NULL, 0);
errflag = lastval = 1;
return;
+ } else if (!nullcmd || !*nullcmd || opts[SHNULLCMD]) {
+ if (!args)
+ args = newlinklist();
+ addlinknode(args, dupstring(":"));
} else if (readnullcmd && *readnullcmd &&
((Redir) peekfirst(redir))->type == READ &&
!nextnode(firstnode(redir))) {
Index: Doc/Zsh/redirect.yo
--- Doc/Zsh/redirect.yo Fri, 31 Dec 1999 13:32:44 +0100 Alexandre
+++ Doc/Zsh/redirect.yo Tue, 08 Feb 2000 23:09:25 +0100 Alexandre
@@ -198,20 +198,28 @@
sect(Redirections with no command)
vindex(NULLCMD, use of)
vindex(READNULLCMD, use of)
-If a simple command consists of one or more redirection operators
-and zero or more parameter assignments, but no command name, and the
-parameter tt(NULLCMD) is not set, an error is caused. If the parameter
-tt(NULLCMD) is set, its value will be inserted as a command with the
-given redirections. If both tt(NULLCMD) and tt(READNULLCMD) are set, then
-the value of the latter will be used instead of that of the former when the
-redirection is an input. The default for tt(NULLCMD) is `tt(cat)' and for
-tt(READNULLCMD) is `tt(more)'. Thus
+pindex(IGNORE_NULLCMD, use of)
+pindex(SH_NULLCMD, use of)
+When a simple command consists of one or more redirection operators
+and zero or more parameter assignments, but no command name, zsh can
+behave in several ways.
+
+If the parameter tt(NULLCMD) is not set or the option tt(CSH_NULLCMD) is
+set, an error is caused. This is the bf(csh) behavior and tt(CSH_NULLCMD)
+is set by default when emulating bf(csh).
+
+If the option (SH_NULLCMD) is set, the builtin tt(`:') is inserted as a
+command with the given redirections. This is the default when emulating
+bf(sh) or bf(ksh).
+
+Otherwise, if the parameter tt(NULLCMD) is set, its value will be used as a
+command with the given redirections. If both tt(NULLCMD) and
+tt(READNULLCMD) are set, then the value of the latter will be used instead
+of that of the former when the redirection is an input. The default for
+tt(NULLCMD) is `tt(cat)' and for tt(READNULLCMD) is `tt(more)'. Thus
example(< file)
shows the contents of tt(file) on standard output, with paging if that is a
terminal. tt(NULLCMD) and tt(READNULLCMD) may refer to shell functions.
-The standard Bourne shell behaviour is obtained by setting tt(NULLCMD) and
-tt(READNULLCMD) to `tt(:)'. This is the default when zsh is emulating bf(sh)
-or bf(ksh).
Index: Doc/Zsh/options.yo
--- Doc/Zsh/options.yo Fri, 31 Dec 1999 13:32:44 +0100 Alexandre
+++ Doc/Zsh/options.yo Tue, 08 Feb 2000 23:18:52 +0100 Alexandre
@@ -305,6 +305,16 @@
or `tt(")' (and `tt(\)' itself no longer needs escaping).
Command substitutions are only expanded once, and cannot be nested.
)
+pindex(CSH_NULLCMD)
+vindex(NULLCMD, ignoring)
+vindex(READNULLCMD, ignoring)
+cindex(redirections with no command, csh)
+cindex(csh, redirections with no command)
+item(tt(IGNORE_NULLCMD) <C>)(
+Do not use the values of tt(NULLCMD) and tt(READNULLCMD)
+when running redirections with no command. This make
+such redirections fail (see noderef(Redirection)).
+)
pindex(CSH_NULL_GLOB)
cindex(csh, null globbing style)
cindex(null globbing style, csh)
@@ -976,7 +986,19 @@
necessarily affect the state the option will have while the shell is
running - that is purely an indicator of whether on not commands are
em(actually) being read from standard input.
-The value of this option cannot be changed anywhere other than the command line.
+The value of this option cannot be changed anywhere other
+than the command line.
+)
+pindex(SH_NULLCMD)
+vindex(NULLCMD, ignoring)
+vindex(READNULLCMD, ignoring)
+cindex(sh, redirections with no command)
+cindex(ksh, redirections with no command)
+cindex(redirections with no command, sh)
+cindex(redirections with no command, ksh)
+item(tt(SH_NULLCMD) <K> <S>)(
+Do not use the values of tt(NULLCMD) and tt(READNULLCMD)
+when doing redirections, use `tt(:)' instead (see noderef(Redirection)).
)
pindex(SH_OPTION_LETTERS)
cindex(sh, single letter options style)
--
Alexandre Duret-Lutz
next prev parent reply other threads:[~2000-02-08 22:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-02-08 10:54 Alexandre Duret-Lutz
2000-02-08 18:07 ` Bart Schaefer
2000-02-08 22:42 ` Alexandre Duret-Lutz [this message]
2000-02-09 18:54 ` Bart Schaefer
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=mvb7lgfgvug.fsf@phobos.lrde.epita.fr \
--to=duret_g@epita.fr \
--cc=schaefer@candle.brasslantern.com \
--cc=zsh-workers@math.gatech.edu \
/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).