From: Dato Simó Date: Mon, 23 Sep 2013 20:47:43 +0000 (+0100) Subject: vcsh: don't allow `clone` to choke on filenames with spaces X-Git-Url: https://git.madduck.net/code/vcsh.git/commitdiff_plain/deec8de709a933763e7344c3a7be54ae0be5577c?ds=sidebyside;hp=--cc vcsh: don't allow `clone` to choke on filenames with spaces By replacing the "for" loop with a "while" loop, it is easy to read line-oriented output without worrying about spaces. However, now the loop executes in a subshell, and VCSH_CONFLICT won't be available in the parent shell. In this case, a trivial, portable solution is to have the comparison as the last command in the subshell. --- deec8de709a933763e7344c3a7be54ae0be5577c diff --git a/vcsh b/vcsh index 5d5628e..6ce5320 100755 --- a/vcsh +++ b/vcsh @@ -152,12 +152,12 @@ clone() { exit fi git fetch - for object in $(git ls-tree -r origin/master | awk '{print $4}'); do + git ls-tree -r --name-only origin/master | (while read object; do [ -e "$object" ] && error "'$object' exists." && VCSH_CONFLICT=1 done - [ "$VCSH_CONFLICT" = '1' ] && + [ "$VCSH_CONFLICT" = '1' ]) && fatal "will stop after fetching and not try to merge! Once this situation has been resolved, run 'vcsh run $VCSH_REPO_NAME git pull' to finish cloning." 17 git merge origin/master