hush: fix handling of '' in ${var:+ARG}

This wasn't an ash bug in dollar_altvalue9, it was hush bug (and bash!)

function                                             old     new   delta
expand_one_var                                      2236    2254     +18
expand_vars_to_list                                 1097    1103      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 24/0)               Total: 24 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2018-07-20 17:36:06 +02:00
parent 294eb4612c
commit 83e434d5b5
7 changed files with 217 additions and 3 deletions

View File

@@ -0,0 +1,69 @@
Unquoted '':
start:
||
end
start:
||
end
start:
||
end
start:
||
end
start:
||
||
end
Unquoted "":
start:
||
end
start:
||
end
start:
||
end
start:
||
end
start:
||
||
end
Quoted '':
start:
|''|
end
start:
|'' |
end
start:
| ''|
end
start:
| '' |
end
start:
|'' ''|
end
Quoted "":
start:
||
end
start:
| |
end
start:
| |
end
start:
| |
end
start:
| |
end

View File

@@ -0,0 +1,33 @@
f() { echo start:; for i; do echo "|$i|"; done; echo end; }
x=a
echo "Unquoted '':"
f ${x:+''}
f ${x:+'' }
f ${x:+ ''}
f ${x:+ '' }
f ${x:+'' ''}
echo
echo 'Unquoted "":'
f ${x:+""}
f ${x:+"" }
f ${x:+ ""}
f ${x:+ "" }
f ${x:+"" ""}
echo
echo "Quoted '':"
f "${x:+''}"
f "${x:+'' }"
f "${x:+ ''}"
f "${x:+ '' }"
f "${x:+'' ''}"
echo
echo 'Quoted "":'
f "${x:+""}"
f "${x:+"" }"
f "${x:+ ""}"
f "${x:+ "" }"
f "${x:+"" ""}"

View File

@@ -3,6 +3,7 @@ Unquoted 1:
|x y|
|1|
|2|
||
|1 2|
|A|
|B|
@@ -14,6 +15,7 @@ Unquoted 2:
|ax y|
|1|
|2|
||
|1 2|
|A|
|B|