Re: [PATCH] man: document what happens when IFS= (and when it's not)

Herbert Xu <[email protected]>
Newsgroups org.kernel.vger.dash
Message-ID <ZhEWPOt67WBRkkf/@gondor.apana.org.au>
On Sat, Apr 22, 2023 at 05:16:21PM +0200, наб wrote:
> A question I just got from a user was "how do I make while read -r l; do
> ...; done < f not strip the initial tabs?". Turns out, the manual is
> silent on this, and POSIX just about implies this behaviour.
> (Indeed, our read is almost verbatim POSIX, and both defer to Field
>  Splitting, but our Field Splitting isn't nearly as detailed,
>  and thank god.)
> Even POSIX spends just one line describing this pivotal behaviour
> (Issue 8 Draft 2.1 line 75044-75045:
> "2. If the value of IFS is null, field splitting shall have no effect,
>     except that if the input is empty the result shall be zero fields.),"
> and when I first encountered this it was also quite surprising to me.
> 
> Spell it out explicitly: IFS= means that input is preserved,
> and the default value means whitespace is stripped from the front.
> Drive it home with an example because it's esoteric (and I know from
>  that user that they first tried searching for read in the manual,
>  but it was not very helpful).
> 
> Reported-by: rozbrajaczpoziomow <[email protected]>
> ---
>  src/dash.1 | 13 +++++++++++++
>  1 file changed, 13 insertions(+)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.