From ed0b5680e2ed2e834081dba02b8969e41ce44f53 Mon Sep 17 00:00:00 2001 From: Doug Borg Date: Tue, 14 Oct 2014 13:28:47 -0600 Subject: [PATCH] For #115: Update link file with newline test. - IFS manipulation did not appear to be doing anything helpful, so I removed it. - Linking files with a newline is not actually fixed, but the behavior did change slightly, so I updated the test. --- lib/commands/link.sh | 9 +++------ test/suites/link.bats | 9 ++++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/commands/link.sh b/lib/commands/link.sh index 84eaf09d..627f46ce 100755 --- a/lib/commands/link.sh +++ b/lib/commands/link.sh @@ -9,16 +9,13 @@ function symlink { ignore 'ignored' "$castle" return $EX_SUCCESS fi - oldIFS=$IFS - IFS=$'\n' - for filename in $(get_repo_files $repo/home); do + for filename in $(get_repo_files "$repo/home"); do remote="$repo/home/$filename" - IFS=$oldIFS - local=$HOME/$filename + local="$HOME/$filename" if [[ -e $local || -L $local ]]; then # $local exists (but may be a dead symlink) - if [[ -L $local && $(readlink "$local") == $remote ]]; then + if [[ -L $local && $(readlink "$local") == "$remote" ]]; then # $local symlinks to $remote. if [[ -d $remote && ! -L $remote ]]; then # If $remote is a directory -> legacy handling. diff --git a/test/suites/link.bats b/test/suites/link.bats index 2c55ef0a..609ddb82 100755 --- a/test/suites/link.bats +++ b/test/suites/link.bats @@ -161,14 +161,13 @@ EOF @test 'fail when linking file with newline' { castle 'rc-files' - touch "$HOMESICK/repos/rc-files/home/filename + test_filename="filename newline" + touch "$HOMESICK/repos/rc-files/home/$test_filename" commit_repo_state $HOMESICK/repos/rc-files $HOMESHICK_FN --batch link rc-files - [ -L "$HOME/\"filename" ] - [ -L "$HOME/newline\"" ] - is_symlink $HOMESICK/repos/rc-files/home/\"filename $HOME/\"filename - is_symlink $HOMESICK/repos/rc-files/home/newline\" $HOME/newline\" + [ -L "$HOME/\"filenamennewline\"" ] + is_symlink "$HOMESICK/repos/rc-files/home/\"filenamennewline\"" "$HOME/\"filenamennewline\"" } @test 'files ignored by git should not be linked' {