hush: never glob result of dquoted "${v:+/bin/c*}"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2018-07-20 19:29:41 +02:00
parent 4c3c8a1a61
commit f36caa4071
5 changed files with 53 additions and 1 deletions

View File

@ -0,0 +1,7 @@
1u: glob_altvalue1.tests
2u: glob_altvalue1.t*
3u: glob_altvalue1.t*
4u: glob_altvalue1.t*
1q: glob_altvalue1.t*
2q: 'glob_altvalue1.t*'
3q: glob_altvalue1.t*

View File

@ -0,0 +1,13 @@
x=x
echo 1u: ${x:+glob_altvalue1.t*}
echo 2u: ${x:+'glob_altvalue1.t*'}
echo 3u: ${x:+"glob_altvalue1.t*"}
echo 4u: ${x:+glob_altvalue1.t\*}
##echo 5u: ${x:+"glob_altvalue1.t\*"}
echo 1q: "${x:+glob_altvalue1.t*}"
echo 2q: "${x:+'glob_altvalue1.t*'}"
echo 3q: "${x:+"glob_altvalue1.t*"}"
##echo 4q: "${x:+glob_altvalue1.t\*}"
##echo 5q: "${x:+"glob_altvalue1.t\*"}"

View File

@ -5994,7 +5994,19 @@ static int encode_then_append_var_plusminus(o_string *output, int n,
continue;
}
#endif
if (dquoted) {
/* Always glob-protect if in dquotes:
* x=x; echo "${x:+/bin/c*}" - prints: /bin/c*
* x=x; echo "${x:+"/bin/c*"}" - prints: /bin/c*
*/
o_addqchr(&dest, ch);
} else {
/* Glob-protect only if char is quoted:
* x=x; echo ${x:+/bin/c*} - prints many filenames
* x=x; echo ${x:+"/bin/c*"} - prints: /bin/c*
*/
o_addQchr(&dest, ch);
}
} /* for (;;) */
if (dest.data) {

View File

@ -0,0 +1,7 @@
1u: glob_altvalue1.tests
2u: glob_altvalue1.t*
3u: glob_altvalue1.t*
4u: glob_altvalue1.t*
1q: glob_altvalue1.t*
2q: 'glob_altvalue1.t*'
3q: glob_altvalue1.t*

View File

@ -0,0 +1,13 @@
x=x
echo 1u: ${x:+glob_altvalue1.t*}
echo 2u: ${x:+'glob_altvalue1.t*'}
echo 3u: ${x:+"glob_altvalue1.t*"}
echo 4u: ${x:+glob_altvalue1.t\*}
##echo 5u: ${x:+"glob_altvalue1.t\*"}
echo 1q: "${x:+glob_altvalue1.t*}"
echo 2q: "${x:+'glob_altvalue1.t*'}"
echo 3q: "${x:+"glob_altvalue1.t*"}"
##echo 4q: "${x:+glob_altvalue1.t\*}"
##echo 5q: "${x:+"glob_altvalue1.t\*"}"