Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: *suggestion* for NULLCMD and emulate [ck]sh
- X-seq: zsh-workers 9625
- From: Alexandre Duret-Lutz <duret_g@xxxxxxxx>
- To: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- Subject: Re: *suggestion* for NULLCMD and emulate [ck]sh
- Date: 08 Feb 2000 23:42:15 +0100
- Cc: Alexandre Duret-Lutz <duret_g@xxxxxxxx>, zsh-workers@xxxxxxxxxxxxxxx
- In-reply-to: "Bart Schaefer"'s message of "Tue, 8 Feb 2000 18:07:00 +0000"
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <mvbog9sotg8.fsf@xxxxxxxxxxxxxxxxxxxx> <1000208180700.ZM31285@xxxxxxxxxxxxxxxxxxxxxxx>
>>> "Bart" == Bart Schaefer <schaefer@xxxxxxxxxxxxxxxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author