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: Chet Ramey
Subject: Re: Bad substitution breaks conditional statement
Date: Wed, 14 Oct 2020 09:30:30 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.3.2

On 10/13/20 11:43 PM, 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.

They are not both syntax errors. The first is a word expanion error. The
second is a syntax error because `;;' is an operator and it's not valid in
that context.


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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