Commit 1bd18205 authored by Christian Couder's avatar Christian Couder

ipfs-test-lib: add shellquote()

This function can be usefull in many places.

See for example:

https://github.com/ipfs/go-ipfs/pull/1742

Git has `git rev-parse --sq-quote` that does the same thing.

License: MIT
Signed-off-by: default avatarChristian Couder <chriscool@tuxfamily.org>
parent 08e06764
......@@ -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'
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment