[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: String replacement drops leading '-e' if replacing char is a space
From: |
Kerin Millar |
Subject: |
Re: String replacement drops leading '-e' if replacing char is a space |
Date: |
Mon, 14 Aug 2023 06:40:28 +0100 |
On Mon, 14 Aug 2023 02:11:27 +0000
pphick via Bug reports for the GNU Bourne Again SHell <bug-bash@gnu.org> wrote:
> If a string starts with '-e' the replacement operators ${x//,/ } and ${x/, /}
> drop the '-e'.
> The behaviour seems to be very specific: the string must start with '-e' and
> the replacing character has to be a space.
>
> Repeat-By:
>
> x='-e,b,c'
> echo ${x//,/ }
> b c
> echo ${x/,/ }
> b,c
This is to be expected. Given that you haven't quoted the expansion, word
splitting occurs, after which echo is run with three arguments. The first of
these arguments is -e, which is treated as an option.
--
Kerin Millar