From: Martijn Dekker <martijn@inlv.org>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] don't exit shell on [[ -o invalid@option ]]
Date: Sat, 11 Nov 2017 19:01:53 +0000 [thread overview]
Message-ID: <38275e86-81c7-dbf8-544e-b0a399a4461d@inlv.org> (raw)
In-Reply-To: <20171111124528.035a70ac@ntlworld.com>
[-- Attachment #1: Type: text/plain, Size: 870 bytes --]
Op 11-11-17 om 12:45 schreef Peter Stephenson:
> On Fri, 10 Nov 2017 14:37:17 -0800
> Bart Schaefer <schaefer@brasslantern.com> wrote:
>> We could certainly suppress the error in emulation modes given that's
>> what other shells do. Further, I'm not strongly invested in the current
>> behavior even for native mode, but we should consider the ramifications.
>
> It's not clear if it matters in practice rather than theory, no. The
> test failing is probably usually good enough.
>
> We could attach it to POSIXBUILTINS as that does control some aspects of
> reutrn / exit behaviour, and [[ ... ]] behaves like a specially parsed
> builtin.
Something like this?
Seems a bit wrong as this is not POSIX at all. Also, POSIXBUILTINS makes
'set -o' exit the shell on an invalid option, which is the opposite
effect. But I can't find a better shell option either.
- M.
[-- Attachment #2: dont-exit-on-testing-invalid-option.patch --]
[-- Type: text/plain, Size: 898 bytes --]
diff --git a/Doc/Zsh/cond.yo b/Doc/Zsh/cond.yo
index e08fc0d..0ea5fc1 100644
--- a/Doc/Zsh/cond.yo
+++ b/Doc/Zsh/cond.yo
@@ -45,6 +45,8 @@ item(tt(-o) var(option))(
true if option named var(option) is on. var(option)
may be a single character, in which case it is a single letter option name.
(See noderef(Specifying Options).)
+If the var(option) does not exist, the shell exits with an error message,
+unless the shell option tt(POSIX_BUILTINS) is set.
)
item(tt(-p) var(file))(
true if var(file) exists and is a FIFO special file (named pipe).
diff --git a/Src/cond.c b/Src/cond.c
index b9a47ce..814f4b0 100644
--- a/Src/cond.c
+++ b/Src/cond.c
@@ -506,6 +506,8 @@ optison(char *name, char *s)
else
i = optlookup(s);
if (!i) {
+ if (isset(POSIXBUILTINS))
+ return 1; /* act like bash and *ksh */
zwarnnam(name, "no such option: %s", s);
return 2;
} else if(i < 0)
next prev parent reply other threads:[~2017-11-11 19:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 18:24 Martijn Dekker
2017-11-10 18:53 ` Eric Cook
2017-11-10 19:03 ` Martijn Dekker
2017-11-10 22:37 ` Bart Schaefer
2017-11-11 12:45 ` Peter Stephenson
2017-11-11 19:01 ` Martijn Dekker [this message]
2017-11-11 23:19 ` Bart Schaefer
2017-11-12 19:56 ` Peter Stephenson
2017-11-14 12:26 ` Daniel Shahaf
2017-11-14 13:22 ` Martijn Dekker
2017-11-14 23:52 ` Daniel Shahaf
2017-11-16 0:52 ` Martijn Dekker
2017-11-18 18:22 ` Daniel Shahaf
2017-11-19 14:46 ` Martijn Dekker
2017-11-19 19:41 ` Bart Schaefer
2017-11-19 19:53 ` Peter Stephenson
2017-11-20 1:22 ` Daniel Shahaf
2017-11-24 21:50 ` Daniel Shahaf
2017-12-03 7:28 ` Mikael Magnusson
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=38275e86-81c7-dbf8-544e-b0a399a4461d@inlv.org \
--to=martijn@inlv.org \
--cc=zsh-workers@zsh.org \
/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).