1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-01 21:51:40 +02:00

zsh-workers/9617

This commit is contained in:
Tanaka Akira 2000-02-08 11:02:23 +00:00
parent e49689cba8
commit a1e0eed861
6 changed files with 42 additions and 16 deletions

View file

@ -533,6 +533,13 @@ of tt(exit) or tt(logout) instead.
However, ten consecutive EOFs will cause the shell to exit anyway,
to avoid the shell hanging if its tty goes away.
)
pindex(IGNORE_NULLCMD)
vindex(NULLCMD, ignoring)
vindex(READNULLCMD, ignoring)
item(tt(IGNORE_NULLCMD) <C> <K> <S>)(
The values of tt(NULLCMD) and tt(READNULLCMD) are not used when running
redirections with no commands (see noderef(Redirection)).
)
pindex(INC_APPEND_HISTORY)
cindex(history, incremental appending to a file)
item(tt(INC_APPEND_HISTORY))(
@ -978,6 +985,14 @@ 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.
)
pindex(SH_NULLCMD)
cindex(sh, redirections with no command)
cindex(ksh, redirections with no command)
item(tt(SH_NULLCMD) <K> <S>)(
If the variable tt(NULLCMD) is unset or if the option tt(IGNORE_NULLCMD)
is set, this option make redirections with no command have the
standard Bourn shell behaviour (see noderef(Redirection)).
)
pindex(SH_OPTION_LETTERS)
cindex(sh, single letter options style)
cindex(ksh, single letter options style)

View file

@ -198,6 +198,8 @@ when tt(MULTIOS) is unset will truncate bar, and write `tt(foo)' into baz.
sect(Redirections with no command)
vindex(NULLCMD, use of)
vindex(READNULLCMD, use of)
pindex(IGNORE_NULLCMD, use of)
pindex(SH_NULLCMD, 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
@ -212,6 +214,15 @@ 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).
The above default behaviour can be affected by the options
tt(IGNORE_NULLCMD) and tt(SH_NULLCMD). tt(SH_NULLCMD) forces the Bourne
shell behaviour when the parameter tt(NULLCMD) is not set (i.e. the
implicit command used with the redirections is `tt(:)'), while
tt(IGNORE_NULLCMD) is used to obtain the same behaviour as if tt(NULLCMD)
was unset.
The standard Bourne shell behaviour is obtained by setting the options
tt(IGNORE_NULLCMD) and tt(SH_NULLCMD). This is the default when zsh is
emulating bf(sh) or bf(ksh). The tt(csh) behaviour can be obtained by
setting only tt(IGNORE_NULLCMD), which is the default when emulating
bf(csh).

View file

@ -1661,11 +1661,16 @@ execcmd(Estate state, int input, int output, int how, int last1)
} else if (varspc) {
nullexec = 2;
break;
} else if (!nullcmd || !*nullcmd ||
(cflags & BINF_PREFIX)) {
} else if (((!nullcmd || !*nullcmd || opts[IGNORENULLCMD])
&& !opts[SHNULLCMD])
||(cflags & BINF_PREFIX)) {
zerr("redirection with no command", NULL, 0);
errflag = lastval = 1;
return;
} else if (!nullcmd || !*nullcmd || opts[IGNORENULLCMD]) {
if (!args)
args = newlinklist();
addlinknode(args, dupstring(":"));
} else if (readnullcmd && *readnullcmd &&
((Redir) peekfirst(redir))->type == READ &&
!nextnode(firstnode(redir))) {

View file

@ -659,17 +659,8 @@ setupvals(void)
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' */

View file

@ -134,6 +134,7 @@ static struct optname optns[] = {
{NULL, "hup", OPT_EMULATE|OPT_ZSH, HUP},
{NULL, "ignorebraces", OPT_EMULATE|OPT_SH, IGNOREBRACES},
{NULL, "ignoreeof", 0, IGNOREEOF},
{NULL, "ignorenullcmd", OPT_EMULATE|OPT_NONZSH, IGNORENULLCMD},
{NULL, "incappendhistory", 0, INCAPPENDHISTORY},
{NULL, "interactive", OPT_SPECIAL, INTERACTIVE},
{NULL, "interactivecomments", OPT_BOURNE, INTERACTIVECOMMENTS},
@ -185,6 +186,7 @@ static struct optname optns[] = {
{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},

View file

@ -1301,6 +1301,7 @@ enum {
HUP,
IGNOREBRACES,
IGNOREEOF,
IGNORENULLCMD,
INCAPPENDHISTORY,
INTERACTIVE,
INTERACTIVECOMMENTS,
@ -1352,6 +1353,7 @@ enum {
SHFILEEXPANSION,
SHGLOB,
SHINSTDIN,
SHNULLCMD,
SHOPTIONLETTERS,
SHORTLOOPS,
SHWORDSPLIT,