help-bash
[Top][All Lists]
Advanced

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

Re: case $var in $list) issue


From: Lawrence Velázquez
Subject: Re: case $var in $list) issue
Date: Fri, 01 Nov 2024 01:17:11 -0400

On Fri, Nov 1, 2024, at 1:00 AM, #!microsuxx wrote:
> ~ $ m=a\|b ; case b in $m) echo ye ; esac
> ~ $ m=a\|b ; case b in a|b) echo ye ; esac
> ye
>
> so vars like a|b dont work ?

Well, they do "work", they just don't result in multiple patterns.
Patterns undergo parameter expansion, but the results of expansions
are not reparsed to determine new patterns.  It's conceptually the
same reason that this only runs echo once:

        $ var='echo hi; echo bye'
        $ $var
        hi; echo bye

https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#index-case

-- 
vq



reply via email to

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