diff --git a/src/exec.rs b/src/exec.rs index f7c8850..dca95e1 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -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; } diff --git a/tests/differential/cases/case_glob_and_fallthrough.sh b/tests/differential/cases/case_glob_and_fallthrough.sh index 092880f..3e2f34b 100644 --- a/tests/differential/cases/case_glob_and_fallthrough.sh +++ b/tests/differential/cases/case_glob_and_fallthrough.sh @@ -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" ;; diff --git a/tests/differential/cases/quote_empty_args.expected b/tests/differential/cases/quote_empty_args.expected index 396aa46..2a2d1f4 100644 --- a/tests/differential/cases/quote_empty_args.expected +++ b/tests/differential/cases/quote_empty_args.expected @@ -1,7 +1,26 @@ status: 0 stderr: empty --- stdout -2 -1 -0 -1 +argc=2 +<> + +argc=2 +<> +<> +argc=2 +<> + +argc=0 +argc=2 +<> + +argc=3 +<> +<> + +argc=0 +argc=1 +<> +argc=2 +<> + diff --git a/tests/differential/cases/quote_empty_args.sh b/tests/differential/cases/quote_empty_args.sh index 2dae922..02a95c6 100644 --- a/tests/differential/cases/quote_empty_args.sh +++ b/tests/differential/cases/quote_empty_args.sh @@ -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