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] A double-quoted empty word ("") is dropped from a command's arguments #299
I have updated to the latest minor and patch version of Strands Shell (built from main @ 5f80040)
I have checked the documentation and this is not expected behavior
I have searched ./issues and there are no duplicates of my issue
Binding
Rust
Strands Shell Version
main @ 5f80040 (crate 0.12.1)
Language Runtime Version
Rust 1.100.0
Operating System
Linux 6.1 (aarch64)
Installation Method
built from source
Steps to Reproduce
strands-shell -c 'f(){ echo $#; }; f "" x; f '"''"' x; x=""; f "$x" y; printf "[%s]" "" x; echo'
Expected Behavior
Same as bash/POSIX sh: a quoted empty word is kept as an empty argument.
2
2
2
[][x]
Actual Behavior
1
2
2
[x]
Only the literal "" word is dropped; '' and "$x" (empty) are kept. Commands then see shifted arguments, e.g. tac -s "" f (from PR #287) fails with missing argument for option '-s', and tac -s "" x f silently uses x as the separator.
Additional Context
Found while reviewing #287; not caused by it (that PR only adds src/commands/tac.rs).
Possible Solution
"" parses to WordPart::DoubleQuoted(vec![]). In expand_part_split (src/exec.rs:587-591 on 5f80040), the DoubleQuoted arm loops over zero parts, so it never calls Segment::push and has_nonsplit stays false. ifs_split (src/exec.rs:637-641) then returns no field for the empty buffer. '' survives because the SingleQuoted arm (src/exec.rs:508-510) always pushes, which sets has_nonsplit.
I tried this patch locally. It fixes the repro above, and "$@" with no positional args still expands to zero words. I did not run the full test suite with it.
WordPart::DoubleQuoted(parts) => {if parts.is_empty(){
segments.last_mut().unwrap().push("",false,false);}for p in parts {
I'd like to work on this. I'll preserve literal empty double-quoted arguments and add regression coverage, including the case where "$@" with no positional parameters must still expand to no arguments.
Activity
ikenyal commentedon Nov 17, 2026
I'd like to work on this. I'll preserve literal empty double-quoted arguments and add regression coverage, including the case where
"$@"with no positional parameters must still expand to no arguments.