提交 a26ad224 作者: Juan Benet

Merge pull request #1757 from ipfs/shell-quote

ipfs-test-lib: add shellquote()
...@@ -22,3 +22,15 @@ test_sort_cmp() { ...@@ -22,3 +22,15 @@ test_sort_cmp() {
sort "$2" >"$2_sorted" && sort "$2" >"$2_sorted" &&
test_cmp "$1_sorted" "$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 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论