From c263d2b097a7c6bb398491e79f8104213046f38c Mon Sep 17 00:00:00 2001 From: Christian HoĢˆltje Date: Thu, 7 Jun 2018 16:23:30 -0400 Subject: avoid cd having issues with paths that begin with - --- bin/lsrc.in | 12 ++++++------ share/rcm.sh.in | 2 +- 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" -- cgit v1.2.3