summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Christian HoĢˆltje <docwhat@gerf.org>2018-06-07 16:23:30 -0400
committerGravatar Mike Burns <mburns@thoughtbot.com>2018-07-06 10:19:20 -0400
commitc263d2b097a7c6bb398491e79f8104213046f38c (patch)
treee7bc097798d773f52e45494b25764c383c25d0c9
parent4c24f176c3dc6b16d3464d4c2e80eef62e5d2673 (diff)
avoid cd having issues with paths that begin with -
-rwxr-xr-xbin/lsrc.in12
-rw-r--r--share/rcm.sh.in2
2 files changed, 7 insertions, 7 deletions
diff --git a/bin/lsrc.in b/bin/lsrc.in
index 5a0774a..6fb6162 100755
--- a/bin/lsrc.in
+++ b/bin/lsrc.in
@@ -6,7 +6,7 @@
pushdir() {
DIR_STACK="$DIR_STACK:$PWD/$1"
$DEBUG "cd'ing to $1 from $PWD with stack $DIR_STACK"
- cd "$1"
+ cd -- "$1"
}
popdir() {
@@ -14,7 +14,7 @@ popdir() {
prior="$(echo "$DIR_STACK" | sed -e "s|:$current$||" | sed -e 's/.*://g')"
DIR_STACK="$(echo "$DIR_STACK" | sed -e 's/:[^:]*$//')"
$DEBUG "cd'ing to $prior from $PWD with stack $DIR_STACK"
- cd "$prior"
+ cd -- "$prior"
}
build_path() {
@@ -318,7 +318,7 @@ $DEBUG "NEVER_UNDOTTED: $NEVER_UNDOTTED"
relative_root_dir="$PWD"
for DOTFILES_DIR in $DOTFILES_DIRS; do
- cd "$relative_root_dir"
+ cd -- "$relative_root_dir"
DOTFILES_DIR="$(eval echo "$DOTFILES_DIR")"
@@ -343,7 +343,7 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do
never_undotted_file_globs="$(dotfiles_dir_excludes "$DOTFILES_DIR" "$NEVER_UNDOTTED")"
$DEBUG "never_undotted_file_globs: $never_undotted_file_globs"
- cd "$DOTFILES_DIR"
+ cd -- "$DOTFILES_DIR"
DIR_STACK=":$DOTFILES_DIR"
host_files="$DOTFILES_DIR/host-$HOSTNAME"
@@ -361,7 +361,7 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do
popdir
fi
- cd "$DOTFILES_DIR"
+ cd -- "$DOTFILES_DIR"
for tag in $TAGS; do
if [ -d "tag-$tag" ]; then
@@ -379,7 +379,7 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do
fi
done
- cd "$DOTFILES_DIR"
+ cd -- "$DOTFILES_DIR"
for escaped_file in ${FILES:-*}; do
file="$(decode "$escaped_file")"
diff --git a/share/rcm.sh.in b/share/rcm.sh.in
index d0387e2..a1c9f40 100644
--- a/share/rcm.sh.in
+++ b/share/rcm.sh.in
@@ -136,7 +136,7 @@ run_hooks() {
# else's dotfiles repository without reviewing the hooks before doing an `rcup`?
find "$hook_file" -type f \( \( -user $LOGNAME -perm -100 \) -o -perm -001 \) \
| sort | while read file; do
- sh -c 'cd "`dirname $1`" && ./"`basename $1`"' arg0 "$file"
+ sh -c 'cd -- "`dirname $1`" && ./"`basename $1`"' arg0 "$file"
done
else
$DEBUG "no $when-$direction hook present for $dotfiles_dir, skipping"