bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bad substitution breaks conditional statement


From: Andreas Schwab
Subject: Re: Bad substitution breaks conditional statement
Date: Wed, 14 Oct 2020 09:51:03 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

On Okt 14 2020, Martin Schulte wrote:

> Consider the following script:
>
>>>>
> #!/bin/bash
>
> echo "${x;:-}" ; echo "Not executed"
> echo "Executed"
>
> echo "${x:-}" ;; echo "Not executed"
> echo "Not executed"
> <<<
>
> It just a source of problems that the two syntactical errors (both caused by 
> an extra semicolon) lead to different behaviour.

The difference being that the first error occurs during execution, while
the latter occurs during parsing.  The latter is also caught by bash -n.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]