Replace built-in shell array quoting with printf %q

This commit is contained in:
Tom "Ravi" Hale
2018-09-12 17:57:46 +07:00
parent 21d155776a
commit 80ec1ad2ad
4 changed files with 81 additions and 36 deletions

View File

@@ -32,20 +32,6 @@ verboseGitCommands() {
unset -f git
}
# Quote the contents of "$@" in single quotes
# Avoid printf '%q' as 'a b' becomes a\ b in both {ba,z}sh
# See also quote_args and double_quote
function token_quote {
if [[ $shell = bash ]]; then
# Single quotes are always added
echo "${@@Q}"
else # zsh
# Single quotes only added when needed
#shellcheck disable=2154 # zsh
echo "${(qq)@}"
fi
}
# Asserts
#-----------------------------------------------------------------------------