From a01e08d6ee5f38338d7779c44cff82c4d069ef21 Mon Sep 17 00:00:00 2001 From: Florian Tham Date: Fri, 24 Feb 2017 23:17:18 +0100 Subject: rcup: handle directory names containing whitespace This commit fixes #197. --- Makefile.am | 3 ++- bin/rcup.in | 11 +++++------ test/rcup-spaces.t | 10 ++++++++++ test/rcup-standalone.t | 7 +++---- 4 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 test/rcup-spaces.t diff --git a/Makefile.am b/Makefile.am index 149db29..613b926 100644 --- a/Makefile.am +++ b/Makefile.am @@ -44,7 +44,8 @@ TESTS = \ test/rcdn-hooks-run-in-order.t \ test/rcup-hooks.t \ test/rcup-hooks-run-in-situ.t \ - test/rcup-hooks-run-in-order.t + test/rcup-hooks-run-in-order.t \ + test/rcup-spaces.t dist_check_SCRIPTS = $(TESTS) dist_check_DATA = test/helper.sh diff --git a/bin/rcup.in b/bin/rcup.in index 2fb592d..910e534 100755 --- a/bin/rcup.in +++ b/bin/rcup.in @@ -34,7 +34,7 @@ print_generated_preface() { # # sh install.sh # -# Environment variables: VERBOSE, CP, LN, MKDIR, RM, DIRNAME, XARGS. +# Environment variables: VERBOSE, CP, LN, MKDIR, RM, DIRNAME. # # env VERBOSE=1 sh install.sh # @@ -52,7 +52,6 @@ print_generated_preface() { : \${MKDIR:=/bin/mkdir} : \${RM:=/bin/rm} : \${DIRNAME:=/usr/bin/dirname} -: \${XARGS:=/usr/bin/xargs} verbose() { if [ "\$VERBOSE" -gt 0 ]; then echo "\$@" @@ -73,7 +72,7 @@ handle_file_cp() { esac fi verbose "'\$1' -> '\$2'" - \$DIRNAME "\$2" | \$XARGS \$MKDIR -p + \$MKDIR -p "\$(\$DIRNAME "\$2")" \$CP -R "\$1" "\$2" } handle_file_ln() { @@ -91,7 +90,7 @@ handle_file_ln() { esac fi verbose "'\$1' -> '\$2'" - \$DIRNAME "\$2" | \$XARGS \$MKDIR -p + \$MKDIR -p "\$(\$DIRNAME "\$2")" \$LN -sf "\$1" "\$2" } PREFACE @@ -145,9 +144,9 @@ is_linked() { handle_dir() { local dest="$1" - $DEBUG "handle_dir $1" + $DEBUG "handle_dir $dest" - dirname "$dest" | xargs $MKDIR -p + $MKDIR -p "$(dirname "$dest")" } handle_file() { diff --git a/test/rcup-spaces.t b/test/rcup-spaces.t new file mode 100644 index 0000000..00c50be --- /dev/null +++ b/test/rcup-spaces.t @@ -0,0 +1,10 @@ + $ . "$TESTDIR/helper.sh" + +Should create symlinks for files in directories with whitespace in their names + + $ mkdir .dotfiles/sub\ dir + > touch .dotfiles/sub\ dir/example + + $ rcup >/dev/null + + $ assert_linked "$HOME/.sub dir/example" "$HOME/.dotfiles/sub dir/example" diff --git a/test/rcup-standalone.t b/test/rcup-standalone.t index 7dd3b58..18ec36c 100644 --- a/test/rcup-standalone.t +++ b/test/rcup-standalone.t @@ -12,7 +12,7 @@ # # sh install.sh # - # Environment variables: VERBOSE, CP, LN, MKDIR, RM, DIRNAME, XARGS. + # Environment variables: VERBOSE, CP, LN, MKDIR, RM, DIRNAME. # # env VERBOSE=1 sh install.sh # @@ -30,7 +30,6 @@ : ${MKDIR:=/bin/mkdir} : ${RM:=/bin/rm} : ${DIRNAME:=/usr/bin/dirname} - : ${XARGS:=/usr/bin/xargs} verbose() { if [ "$VERBOSE" -gt 0 ]; then echo "$@" @@ -51,7 +50,7 @@ esac fi verbose "'$1' -> '$2'" - $DIRNAME "$2" | $XARGS $MKDIR -p + $MKDIR -p "$($DIRNAME "$2")" $CP -R "$1" "$2" } handle_file_ln() { @@ -69,7 +68,7 @@ esac fi verbose "'$1' -> '$2'" - $DIRNAME "$2" | $XARGS $MKDIR -p + $MKDIR -p "$($DIRNAME "$2")" $LN -sf "$1" "$2" } handle_file_ln "*eggplant_firetruck/lampshade/bottle" "*.eggplant_firetruck/lampshade/bottle" (glob) -- cgit v1.2.3