Merge pull request #1757 from ipfs/shell-quote

ipfs-test-lib: add shellquote()
This commit is contained in:
Juan Benet 2015-09-27 03:29:37 -04:00
commit a26ad22434

View File

@ -22,3 +22,15 @@ test_sort_cmp() {
sort "$2" >"$2_sorted" &&
test_cmp "$1_sorted" "$2_sorted"
}
# Quote arguments for sh eval
shellquote() {
_space=''
for _arg
do
printf '%s' "$_space"
printf '%s' "$_arg" | sed -e "s/'/'\\\\''/g; s/^/'/; s/\$/'/;"
_space=' '
done
printf '\n'
}