bug-bash
[Top][All Lists]
Advanced

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

One IFS non-whitespace is stripped at the end of a word during word spli


From: Yuri Kanivetsky
Subject: One IFS non-whitespace is stripped at the end of a word during word splitting
Date: Sun, 8 Dec 2024 10:27:33 +0200

Hi,

I was trying to understand the part of the documentation on word
splitting. I realized that without some experiments:

https://gist.github.com/x-yuri/6c6b375e7b0721a323960baaedf2a649

I wasn't sure I understood it correctly. And one of the experiments
revealed that:

$ bash -c 'IFS=x; a=xa; f() { for arg; do echo "($arg)"; done; }; f $a'
()
(a)

$ bash -c 'IFS=x; a=ax; f() { for arg; do echo "($arg)"; done; }; f $a'
(a)

$ bash --version
GNU bash, version 5.2.37(1)-release (x86_64-pc-linux-gnu)

I.e. IFS non-whitespaces are not stripped at the beginning of a word,
but if there's one such non-whitespace at the end, it is stripped.
This looks like a bug, unless I'm missing something.

Regards,
Yuri



reply via email to

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