Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] don't exit shell on [[ -o invalid@option ]]



On Fri, Nov 24, 2017 at 10:50 PM, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> Daniel Shahaf wrote on Mon, Nov 20, 2017 at 01:22:41 +0000:
>> I'm quite swamped this week (in a good way) but when I get a chance I'll
>> finish the patch and push.  (Needs more tests and a README blurb, at least)
>
> Interdiff:
>
> diff --git a/README b/README
> index 6fad1d516..59abf29b2 100644
> --- a/README
> +++ b/README
> @@ -54,6 +54,18 @@ foo=([aeiou]\=vowel)
>  This is only required for array values contained within parentheses;
>  command line expansion for normal arguments has not changed.
>
> +3) The syntax
> +
> +[[ -o foo ]]
> +
> +where foo is not the name of a shell option (with optional underscores
> +and optional "no" prefix) used to be treated as a syntax error, i.e.,
> +the enclosing command line or file were aborted.  It now emits a warning
> +and returns a non-zero exit code.  For further details, see the
> +documentation of the -o switch in the chapter "Conditional Expressions"
> +in the zshmisc(1) manual.

I don't know if it's also worth pointing out that you can do
{ [[ -o invalid_option ]] } always { TRY_BLOCK_ERROR=0 }
since 4.2.1 or so? (It will suppress the syntax error but preserve the
return code).

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author