mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-05 19:35:48 +03:00
Improve quote_args output readability
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
@@ -24,12 +24,14 @@ quote_args() {
|
|||||||
local args=("$@")
|
local args=("$@")
|
||||||
s=""
|
s=""
|
||||||
for a in "${args[@]}"; do
|
for a in "${args[@]}"; do
|
||||||
simple_pattern='^[[:alnum:] _=+-]*$'
|
simple_pattern='^([[:alnum:]_+-]+=)?([[:alnum:] _=+-]*)$'
|
||||||
if [[ $a =~ ' ' && $a =~ $simple_pattern ]]; then
|
if [[ $a =~ ' ' && $a =~ $simple_pattern ]]; then
|
||||||
# a has spaces, but no other special characters that need escaping
|
# a has spaces, but no other special characters that need escaping
|
||||||
# (quoting after removing spaces yields no backslashes)
|
# (quoting after removing spaces yields no backslashes)
|
||||||
# simplify quoted form to "$a" - e.g. yield "a b c" instead of a\ b\ c
|
# simplify quoted form - e.g.:
|
||||||
q="\"$a\""
|
# a b -> "a b"
|
||||||
|
# CFLAGS=a b -> CFLAGS="a b"
|
||||||
|
q="${BASH_REMATCH[1]}\"${BASH_REMATCH[2]}\""
|
||||||
else
|
else
|
||||||
# get bash to do the quoting
|
# get bash to do the quoting
|
||||||
q=$(printf '%q' "$a")
|
q=$(printf '%q' "$a")
|
||||||
|
@@ -24,12 +24,14 @@ quote_args() {
|
|||||||
local args=("$@")
|
local args=("$@")
|
||||||
s=""
|
s=""
|
||||||
for a in "${args[@]}"; do
|
for a in "${args[@]}"; do
|
||||||
simple_pattern='^[[:alnum:] _=+-]*$'
|
simple_pattern='^([[:alnum:]_+-]+=)?([[:alnum:] _=+-]*)$'
|
||||||
if [[ $a =~ ' ' && $a =~ $simple_pattern ]]; then
|
if [[ $a =~ ' ' && $a =~ $simple_pattern ]]; then
|
||||||
# a has spaces, but no other special characters that need escaping
|
# a has spaces, but no other special characters that need escaping
|
||||||
# (quoting after removing spaces yields no backslashes)
|
# (quoting after removing spaces yields no backslashes)
|
||||||
# simplify quoted form to "$a" - e.g. yield "a b c" instead of a\ b\ c
|
# simplify quoted form - e.g.:
|
||||||
q="\"$a\""
|
# a b -> "a b"
|
||||||
|
# CFLAGS=a b -> CFLAGS="a b"
|
||||||
|
q="${BASH_REMATCH[1]}\"${BASH_REMATCH[2]}\""
|
||||||
else
|
else
|
||||||
# get bash to do the quoting
|
# get bash to do the quoting
|
||||||
q=$(printf '%q' "$a")
|
q=$(printf '%q' "$a")
|
||||||
|
Reference in New Issue
Block a user