summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Mike Burns <mike@mike-burns.com>2013-08-03 12:23:08 -0400
committerGravatar Mike Burns <mike@mike-burns.com>2013-08-03 12:23:08 -0400
commit5ebd40d8ab1d4806924476a3853edb101ca0a6ff (patch)
treec9449ad44edc4d95b0013b2eb0569b1b250ab6d8
parent9e16a4aea0dad1909abc78b3f9bc1291917486db (diff)
Bugfix: support -t and -d again
Due to the awesome refactoring in fe3244ca9c8c9a38ea700851e36667b1015d11e6, the `-t` and `-d` options were broken. Fix it by removing the `handle_metadata_flags` function and inlining the code again, and build the `LS_ARGS` argument differently. Clearly I need a test suite.
-rwxr-xr-xbin/lsrc19
-rwxr-xr-xbin/rcup36
2 files changed, 31 insertions, 24 deletions
diff --git a/bin/lsrc b/bin/lsrc
index d5e335e..a7eca40 100755
--- a/bin/lsrc
+++ b/bin/lsrc
@@ -82,10 +82,10 @@ metafile() {
}
handle_command_line() {
- arg_tags=""
- verbosity=0
- version=0
- dotfiles_dirs=""
+ local arg_tags=
+ local verbosity=0
+ local version=0
+ local dotfiles_dirs=
while getopts Vqvt:d: opt; do
case "$opt" in
@@ -99,8 +99,12 @@ handle_command_line() {
shift $(($OPTIND-1))
handle_common_flags lsrc $version $verbosity
- handle_metadata_flags $arg_tags $dotfiles_dirs
+ TAGS=${arg_tags:-$TAGS}
+ DOTFILES_DIRS=${dotfiles_dirs:-$DOTFILES_DIRS}
FILES=$@
+
+ $DEBUG "TAGS: $TAGS"
+ $DEBUG "DOTFILES_DIRS: $DOTFILES_DIRS"
}
DEST_STACK=
@@ -111,9 +115,8 @@ fi
handle_command_line $*
-if [ "x$DOTFILES_DIRS" = "x" ]; then
- DOTFILES_DIRS="$DOTFILES_DIRS $DEFAULT_DOTFILES_DIR"
-fi
+: ${DOTFILES_DIRS:=$DOTFILES_DIRS $DEFAULT_DOTFILES_DIR}
+$DEBUG "DOTFILES_DIRS: $DOTFILES_DIRS"
for DOTFILES_DIR in $DOTFILES_DIRS; do
diff --git a/bin/rcup b/bin/rcup
index c2e33dd..9a0e82b 100755
--- a/bin/rcup
+++ b/bin/rcup
@@ -73,33 +73,37 @@ handle_file() {
}
handle_command_line() {
- arg_tags=""
- verbosity=0
- version=0
- dotfiles_dirs=""
- LS_ARGS=
+ local arg_tags=
+ local verbosity=0
+ local version=0
+ local dotfiles_dirs=
+ local files=
while getopts Vqvt:d: opt; do
case "$opt" in
- t)
- arg_tags="$arg_tags $OPTARG"
- LS_ARGS="$LS_ARGS -t $OPTARG"
- ;;
+ t) arg_tags="$arg_tags $OPTARG" ;;
v) verbosity=$(($verbosity + 1));;
q) verbosity=$(($verbosity - 1));;
- d)
- dotfiles_dirs="$dotfiles_dirs $OPTARG"
- LS_ARGS="$LS_ARGS -d $OPTARG"
- ;;
+ d) dotfiles_dirs="$dotfiles_dirs $OPTARG" ;;
V) version=1
esac
done
shift $(($OPTIND-1))
handle_common_flags rcup $version $verbosity
- handle_metadata_flags $arg_tags $dotfiles_dirs
- FILES=$@
- LS_ARGS="$LS_ARGS $FILES"
+
+ tags=${arg_tags:-$TAGS}
+ dotfiles_dirs=${dotfiles_dirs:-$DOTFILES_DIRS}
+ files=$@
+
+ for tag in $tags; do
+ LS_ARGS="$LS_ARGS -t $tag"
+ done
+ for dotfiles_dir in $dotfiles_dirs; do
+ LS_ARGS="$LS_ARGS -d $dotfiles_dir"
+ done
+ LS_ARGS="$LS_ARGS $files"
+
$DEBUG "LS_ARGS: $LS_ARGS"
}