[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible problem with ${var%%[...]*}
From: |
Robert Elz |
Subject: |
Re: Possible problem with ${var%%[...]*} |
Date: |
Mon, 03 Apr 2023 00:28:25 +0700 |
Date: Sun, 2 Apr 2023 17:48:24 +0200
From: Martin Schulte <gnu@schrader-schulte.de>
Message-ID: <20230402174824.01db4d51fd4f0061fdba76cd@schrader-schulte.de>
| in the following lines I consider dash's behaviour as correct
| an bash's as wrong:
All other shells (even ksh93) not just dash.
I suspect the issue is that the string after %% is not regarded as
quoted, even when the expansion is, and that in
| $ bash -c 'option2="test{<().["; echo "${option2%%[<().[]*}"'
bash is parsing the <() as a process substitution, producing nothing.
The only chars in the bracket expression will then be . and [ which
explains the result.
Try instead
bash -c 'option2="test{<().["; echo "${option2%%[\<().[]*}"'
and you'll see the difference. That form should work for all shells.
kre