[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using ‘;&’ in place of ‘;;’ in case statement
From: |
Andreas Kusalananda Kähäri |
Subject: |
Re: Using ‘;&’ in place of ‘;;’ in case statement |
Date: |
Mon, 13 Dec 2021 09:44:51 +0100 |
On Mon, Dec 13, 2021 at 07:34:45AM +0100, Alex fxmbsw7 Ratchev wrote:
> args=abc ; case $args in *a*) printf a\\n ;& *b*) printf b\\n ;& esac
> a
> b
>
Note that the text never says anything about the case pattern for the
next clause having to match at all:
$ args=abc; case $args in *a*) echo a ;& *q*) echo b; esac
a
b
If you need the next pattern to match, use ;;&
$ args=abc; case $args in *a*) echo a ;;& *q*) echo b; esac
a
$ args=aqc; case $args in *a*) echo a ;;& *q*) echo b; esac
a
b
> On Mon, Dec 13, 2021, 05:27 fatiparty--- via <help-bash@gnu.org> wrote:
>
> >
> > I am reading the Gnu Bash Manual "3.2.5.2 Conditional Constructs".
> >
> > In the "case" part, the manual states that
> >
> > Using ‘;&’ in place of ‘;;’ causes execution to continue withthe
> > command-list associated with the next clause, if any.
> >
> > How can one clause cause a match, then continue to another clause that
> > causes an additional match?
> >
--
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden
.