Skip to content

Commit 088aa1a

Browse files
committedOct 3, 2015
ipfs-test-lib: clarify and simplify shellquote()
Let's first add a comment to explain why the wrapper printf() is needed. Then let's replace the last instructions by quotes inside the wrapper printf() first argument, and let's also put there the eventual space so that we can remove the printf on the above line. License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
1 parent 4cab9fe commit 088aa1a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎test/ipfs-test-lib.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ shellquote() {
2828
_space=''
2929
for _arg
3030
do
31-
printf '%s' "$_space"
32-
printf '%s' "$(printf '%s' "$_arg" | sed -e "s/'/'\\\\''/g; s/^/'/; s/\$/'/;")"
31+
# On Mac OS, sed adds a newline character.
32+
# With a printf wrapper the extra newline is removed.
33+
printf "$_space'%s'" "$(printf "%s" "$_arg" | sed -e "s/'/'\\\\''/g;")"
3334
_space=' '
3435
done
3536
printf '\n'

0 commit comments

Comments
 (0)
Please sign in to comment.