Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,9 @@ fn expand_part_split<'a>(
segments.last_mut().unwrap().push(&tmp, false, false);
}
WordPart::DoubleQuoted(parts) => {
if parts.is_empty() {
segments.last_mut().unwrap().push("", false, false);
}
for p in parts {
expand_part_split(os.clone(), proc, p, segments, ifs, true).await;
}
Expand Down
1 change: 0 additions & 1 deletion tests/differential/cases/case_glob_and_fallthrough.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# known-difference: a case pattern of "" never matches an empty word
for v in yes Y no maybe "" ; do
case "$v" in
[Yy]|[Yy]es) echo "[$v] yes" ;;
Expand Down
27 changes: 23 additions & 4 deletions tests/differential/cases/quote_empty_args.expected
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
status: 0
stderr: empty
--- stdout
2
1
0
1
argc=2
<>
<x>
argc=2
<>
<>
argc=2
<>
<x>
argc=0
argc=2
<>
<y>
argc=3
<>
<>
<ab>
argc=0
argc=1
<>
argc=2
<>
<x>
22 changes: 15 additions & 7 deletions tests/differential/cases/quote_empty_args.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# known-difference: f "" "" passes no arguments; bash passes two empty ones
f() { echo "$#"; }
f "" ""
f ''
e=
f $e
f "$e"
show() {
printf 'argc=%s\n' "$#"
for arg in "$@"; do printf '<%s>\n' "$arg"; done
}
show "" x
show "" ""
show '' x
empty=
show $empty
show "$empty" y
show """" ""'' a""b
show "$@"
show "" "$@"
forward() { show "$@"; }
forward '' x
Loading