Skip to content

Commit

Permalink
Merge pull request #60 from mobilemind/exit-on-cd-fail
Browse files Browse the repository at this point in the history
quote directory names & warn if cd fails
  • Loading branch information
aurora authored Jun 23, 2017
2 parents 5f2c73b + afee21b commit f880219
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rmate
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function log {
}

function dirpath {
(cd `dirname "$1"` >/dev/null 2>/dev/null; pwd -P)
(cd "`dirname "$1"`" >/dev/null 2>/dev/null || { echo "unable to cd to $1 directory" 1>&2; exit; } ; pwd -P)
}

function canonicalize {
Expand All @@ -135,7 +135,7 @@ function canonicalize {

dir=`dirpath "$filepath"`
if [ -L "$filepath" ]; then
relativepath=`cd "$dir"; readlink \`basename "$filepath"\``
relativepath=`cd "$dir" || { echo "unable to cd to $dir" 1>&2; exit; } ; readlink "\`basename "$filepath"\`"`
result=`dirpath "$relativepath"`/`basename "$relativepath"`
else
result=`basename "$filepath"`
Expand Down

0 comments on commit f880219

Please sign in to comment.