bug-bash
[Top][All Lists]
Advanced

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

Fwd: Strange results


From: Victor Pasko
Subject: Fwd: Strange results
Date: Fri, 27 Oct 2023 02:00:01 +0700

---------- Forwarded message ---------
From: Victor Pasko <victor.pasko@gmail.com>
Date: Fri, Oct 27, 2023 at 1:57 AM
Subject: Re: Strange results
To: Dennis Williamson <dennistwilliamson@gmail.com>



Also

echo10 ${ASCII_SET:$((-10)):1}

and

echo11 ${ASCII_SET:-10:1}

have different behaviour:(

Both of these say "output the character that's 10th from the end" which is
> "u". What did you expect it to output?
>
> echo "echo11 ${ASCII_SET:-10:1}"
>

Firstly, expected the only one symbol from  ASCII_SET string

This says, according to the man page:
>
>        ${parameter:-word}
>               Use Default Values.  If parameter is unset or null, the
> expansion of word is substituted.  Otherwise, the value of parameter is
> substituted
>
> which means output "10:1" if ASCII_SET is unset or null. Since it isn't,
> the contents of that variable are output giving you a long sequence of
> ASCII characters.
>

But ASCII_SET is not unset so -word must not be used

-- 

-- PSK


-- 

-- PSK


reply via email to

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