[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash bug?
From: |
Greg Wooledge |
Subject: |
Re: Bash bug? |
Date: |
Tue, 24 Jan 2023 09:21:47 -0500 |
On Tue, Jan 24, 2023 at 06:27:28PM +0800, Po Lu wrote:
> mapfile "-d " -t FOO <<<"1 2 3" ; for i in "${FOO[@]}"; do echo
> "x${i}x"; done
>
> gives:
>
> x1x
> x2x
> x3
> x
>
> but since I specified -t, I would have expected that the delimiter be
> removed from the end of each delimited input ``line''.
You specified that the delimiter is a space, and the spaces were removed
from each element. However, the <<< operator adds a newline to the
input stream, and the newline character is NOT the delimiter you asked
for, so it's NOT removed.
If you want to send an input stream without adding a newline to it, you
can use < <(printf %s "$var") instead of <<< "$var".
- Bash bug?, Po Lu, 2023/01/24
- Re: Bash bug?,
Greg Wooledge <=