On 02/12/2015 23:37, Gioele Barabucci wrote: > Hello, > > I am forwarding a bug [1] reported by a Debian user: `read` does not > ignore trailing spaces. The current version of dash is affected by > this bug. > > A simple test from the original reporter: > > $ dash -c 'echo " a b " | { read v ; echo "<$v>" ; }' > > > $ bash -c 'echo " a b " | { read v ; echo "<$v>" ; }' > > > Other shells like posh and mksh behave like bash. This is indeed a bug based on the current specification. In the past, the specification was unclear and the dash interpretation was a legitimate one, but currently it explicitly spells out that trailing IFS whitespace gets ignored. However, unless I'm misreading the spec, mksh and bash don't seem to implement it properly either: only trailing IFS whitespace is supposed to be dropped. IFS non-whitespace is supposed to remain, even at the end of the input. mksh and bash remove it, posh and zsh leave it in: $ for shell in bash mksh posh zsh; do printf %s: "$shell"; $shell -c 'IFS=,; echo a, | { read v; echo "<$v>"; }'; done bash: mksh: posh: zsh: As far as I can tell, the posh/zsh behaviour is the correct behaviour, but I'm not convinced yet my interpretation is correct. Attached is a not fully tested proof of concept to implement the posh/zsh behaviour in dash by extending ifsbreakup() to allow specifying a maximum number of arguments instead of fixing it up in readcmd_handle_line(). It returns in your test, and in mine. Feedback welcome. Cheers, Harald van Dijk > This error is reproducible with dash 0.5.7 and with the current master > git master branch, commit 2e5842258bd5b252ffdaa630db09c9a19a9717ca. > > [1] https://bugs.debian.org/794965 > > -- > Gioele Barabucci