diff options
author | The Linux Kitten <kitten@openbsdbox> | 2014-03-09 21:22:02 +0100 |
---|---|---|
committer | Mike Burns <mike@mike-burns.com> | 2014-03-19 13:24:00 +0100 |
commit | 85e16216d4f95a3986ce18d3e5a4a5ed431a4ad5 (patch) | |
tree | b6589a397729daaeeb7be4c1dbc347ccf18d384d /share/rcm.sh.in | |
parent | 937e565856a05a32060a43d2ee695443cf6c6af1 (diff) |
Add support for -v option on OpenBSD
The `-v` (verbose) flag for `cp`, `ln`, and `rm` is not standard. It is
simple to implement using shell functions, so introduce `cp_v`, `ln_v`,
and `rm_v`. These shell functions use the existing `$VERBOSE` variable
for printing, which simplifies the code and reduces the number of
variables.
Fixes #61.
Diffstat (limited to 'share/rcm.sh.in')
-rw-r--r-- | share/rcm.sh.in | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/share/rcm.sh.in b/share/rcm.sh.in index bccc0a9..bcf3dce 100644 --- a/share/rcm.sh.in +++ b/share/rcm.sh.in @@ -8,16 +8,32 @@ PRINT=echo PROMPT=echo_n ERROR=echo_error VERBOSE=: -MKDIR=mkdir -LN="ln -s" -CP="cp -R" -RM=rm DEFAULT_DOTFILES_DIR="$HOME/.dotfiles" -MV=mv +MKDIR=mkdir INSTALL=rcup ROOT_DIR="$HOME" HOSTNAME="$(hostname | sed -e 's/\..*//')" +ln_v() { + $VERBOSE "'$1' -> '$2'" + ln -s "$1" "$2" +} + +cp_v() { + $VERBOSE "'$1' -> '$2'" + cp -R "$1" "$2" +} + +rm_v() { + $VERBOSE "removed '$2'" + rm $1 "$2" +} + +mv_v() { + $VERBOSE "'$1' -> '$2'" + mv "$1" "$2" +} + unset CDPATH echo_n() { @@ -61,28 +77,16 @@ handle_common_flags() { DEBUG=echo_stderr VERBOSE=echo PRINT=echo - MV="$MV -v" - RM="$RM -v" - LN="$LN -v" - CP="$CP -v" INSTALL="$INSTALL -vv" elif [ $verbosity -eq 1 ]; then DEBUG=: VERBOSE=echo PRINT=echo - MV="$MV -v" - RM="$RM -v" - LN="$LN -v" - CP="$CP -v" INSTALL="$INSTALL -v" elif [ $verbosity -eq 0 ]; then DEBUG=: VERBOSE=: PRINT=echo - MV="$MV -v" - RM="$RM -v" - LN="$LN -v" - CP="$CP -v" else DEBUG=: VERBOSE=: |