summaryrefslogtreecommitdiff
path: root/bin/mkrc
diff options
context:
space:
mode:
authorGravatar Mike Burns <mike@mike-burns.com>2013-08-02 14:27:44 -0400
committerGravatar Mike Burns <mike@mike-burns.com>2013-08-02 14:27:44 -0400
commitfe3244ca9c8c9a38ea700851e36667b1015d11e6 (patch)
tree3c0f61030cc37250844d914c25ffaff672330698 /bin/mkrc
parentaacff1b269a39c967f84ab33b68f827febee8891 (diff)
Extra argument parsing into rcm.sh
Pull the `-V`, `-v`, `-q`, `-t`, and `-d` out into the `handle_common_flags` and `handle_metadata_flags` functions, shared between the different programs.
Diffstat (limited to 'bin/mkrc')
-rwxr-xr-xbin/mkrc28
1 files changed, 4 insertions, 24 deletions
diff --git a/bin/mkrc b/bin/mkrc
index 5de894c..057c172 100755
--- a/bin/mkrc
+++ b/bin/mkrc
@@ -1,12 +1,7 @@
#!/bin/sh
-# set -x
-
-DEFAULT_DOTFILES_DIR=$HOME/.dotfiles
-MV=mv
-INSTALL=rcup
-ROOT_DIR=$HOME
-
+: ${RCM_LIB:=`dirname $0`/../share/rcm}
+. $RCM_LIB/rcm.sh
destination() {
if [ $# -eq 2 ]; then
@@ -20,8 +15,6 @@ if [ -e $HOME/.rcrc ]; then
. $HOME/.rcrc
fi
-. `dirname $0`/../share/rcm/rcm.sh
-
if [ $# -eq 0 ]; then
echo "Usage: mkrc [-d dir] [-t tag] [-v] [-q] filename ..."
exit 1
@@ -46,25 +39,12 @@ while getopts Vvqt:d: opt; do
done
shift $(($OPTIND-1))
-if [ $version -eq 1 ]; then
- version mkrc
- exit 0
-elif [ $verbosity -ge 2 ]; then
- MV="$MV -v"
- INSTALL="$INSTALL -vv"
-elif [ $verbosity -eq 1 ]; then
- MV="$MV -v"
- INSTALL="$INSTALL -v"
-elif [ $verbosity -eq 0 ]; then
- MV="$MV -v"
-else
- INSTALL="$INSTALL -q"
-fi
+handle_common_flags mkrc $version $verbosity
files=$@
for file in $files; do
- dotless=`echo $file | sed -e "s|$ROOT_DIR/||" | sed -e 's/^\.//'`
+ dotless=`echo $file | sed -e "s|$DEST_DIR/||" | sed -e 's/^\.//'`
dest=`destination $DOTFILES_DIR $dotless $tag`
mkdir -p $dest/`dirname $dotless`
$MV $file $dest/$dotless