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 /bin | |
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 'bin')
-rwxr-xr-x | bin/mkrc | 2 | ||||
-rwxr-xr-x | bin/rcdn | 2 | ||||
-rwxr-xr-x | bin/rcup | 9 |
3 files changed, 7 insertions, 6 deletions
@@ -82,7 +82,7 @@ for file in $files; do dest="$(destination "$DOTFILES_DIR" "$dotless" $in_host "$tag")" mkdir -p "$dest/$(dirname "$dotless")" $PRINT "Moving..." - $MV "$file" "$dest/$dotless" + mv_v "$file" "$dest/$dotless" $PRINT "Linking..." $INSTALL -d "$DOTFILES_DIR" -t "${tag:--}" "$dotless" done @@ -11,7 +11,7 @@ remove_link() { if [ "x$dest" = "x/" ]; then $VERBOSE "not a symlink, skipping: $original" elif [ -L "$dest" -o "x$sigil" = "xX" ]; then - $RM -rf "$dest" + rm_v -rf "$dest" rmdir -p "$(dirname "$original")" 2>/dev/null else remove_link "$(dirname "$dest")" "$original" @@ -8,7 +8,7 @@ link_or_copy() { local sigil="$1" if [ "x$sigil" = "xX" ]; then - echo "$CP" + echo "cp_v" else echo "$LN" fi @@ -20,7 +20,7 @@ link_file() { local sigil="$3" if [ -h "$dest" ]; then - $RM -f "$dest" + rm_v -f "$dest" fi action="$(link_or_copy "$sigil")" @@ -35,7 +35,7 @@ replace_file() { $DEBUG replace_file "$1" "$2" $3 - $RM -rf "$dest" + rm_v -rf "$dest" link_file "$src" "$dest" "$sigil" } @@ -126,8 +126,9 @@ handle_command_line() { done shift $(($OPTIND-1)) + LN="ln_v" if [ $always_copy -eq 1 ]; then - LN="$CP" + LN="cp_v" fi handle_common_flags rcup $version $verbosity |