You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] read var keeps leading and trailing whitespace that bash strips #343
As in bash 5.2: [a b], [a][b] and eq. When a variable name is given, read strips leading and trailing IFS whitespace (space, tab, newline that are in IFS) from the line.
Actual Behavior
[ a b ], [a][b ] and ne [ 42]. A single variable gets the line untouched, and the last of several variables keeps the trailing whitespace.
read with no name (REPLY) and IFS=; read x correctly keep the whitespace, same as bash.
Additional Context
src/builtins/read.rs: the single-variable branch assigns the whole line (proc.set_env(vars[0], &line)), and the multi-variable branch only trims the start of the remainder. Padded values then fail string comparisons, for example a count read from wc output.
With #307, read -d DELIM x trims trailing IFS whitespace but not leading (printf ' a\n' | read -d '' x gives a, bash gives a), so the same fix should cover that path.
When at least one name was given, trim leading and trailing characters that are both in IFS and one of space, tab or newline, before splitting. Leave REPLY untouched.
Activity