summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2017-12-02 11:40:22 +0100
committerDominique Martinet <asmadeus@codewreck.org>2017-12-02 11:40:22 +0100
commit3b7b85fe96ba51a81f730d87a60d6c3987071d15 (patch)
treeb035e7280192f68499835acd9eed67257a4cdb78
parent920a5de091655d6df2761694199cdd4e15297b31 (diff)
sparkle some more verbose + add -- separator to some commands
-rwxr-xr-xmcp.sh18
1 files changed, 9 insertions, 9 deletions
diff --git a/mcp.sh b/mcp.sh
index ef659e8..e3d02d2 100755
--- a/mcp.sh
+++ b/mcp.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-VERBOSE=
+VERBOSE=${VERBOSE:-}
error() {
echo "ERROR: " "$@"
@@ -13,7 +13,7 @@ cp-dir() {
for DIR in "$@"; do
DSTDIR="$DST/$DIR"
- find "$DIR" -maxdepth 1 -not -type d -execdir sh -c 'DSTDIR="$1"; shift; cp -a${VERBOSE+v} "$@" "$DSTDIR"' -- "$DSTDIR" {} +
+ find "$DIR" -maxdepth 1 -not -type d -execdir sh -c 'DSTDIR="$1"; shift; cp -a${VERBOSE+v} -- "$@" "$DSTDIR"' -- "$DSTDIR" {} +
done
}
export -f cp-dir
@@ -24,9 +24,9 @@ mk-dirs() {
for DIR in "$@"; do
DSTDIR="$DST/$DIR"
- [[ -d "$DSTDIR" ]] || mkdir ${VERBOSE+-v} "$DSTDIR"
- chown --reference "$DIR" "$DSTDIR"
- chmod --reference "$DIR" "$DSTDIR"
+ [[ -d "$DSTDIR" ]] || mkdir ${VERBOSE+-v} -- "$DSTDIR"
+ chown ${VERBOSE+-v} --reference "$DIR" -- "$DSTDIR"
+ chmod ${VERBOSE+-v} --reference "$DIR" -- "$DSTDIR"
done
}
export -f mk-dirs
@@ -37,7 +37,7 @@ fixstamp-dirs() {
for DIR in "$@"; do
DSTDIR="$DST/$DIR"
- touch --reference "$DIR" "$DSTDIR"
+ touch --reference "$DIR" -- "$DSTDIR"
done
}
export -f fixstamp-dirs
@@ -57,8 +57,8 @@ main() {
[[ "$#" == 1 ]] || error "$0: target '$DEST' is not a directory"
# Handle single file source separately... You're
# calling the wrong script
- [[ -d "$1" ]] || exec cp -a${VERBOSE+v} "$1" "$DEST"
- mkdir -p "$DEST"
+ [[ -d "$1" ]] || exec cp -a${VERBOSE+v} -- "$1" "$DEST"
+ mkdir ${VERBOSE+-v} -- "$DEST"
CREATED_DEST=1
fi
exec {DESTFD}<"$DEST"
@@ -76,7 +76,7 @@ main() {
# Also get single files/etc out of the way first, don't
# use this script for that!!
if [[ ! -d "$SRC" ]]; then
- cp -a "$SRC" "$DEST"
+ cp -a${VERBOSE+v} -- "$SRC" "$DEST"
continue
fi
if ((CREATED_DEST)); then