diff options
Diffstat (limited to 'saferm')
-rwxr-xr-x | saferm | 38 |
1 files changed, 18 insertions, 20 deletions
@@ -5,35 +5,33 @@ realrm="$(which rm)" copy="$(which cp) -R" if [ $# -eq 0 ]; then - exec $realrm + exec $realrm fi flags="" -while getopts "dfiPRrvW" opt -do - case $opt in - f ) exec $realrm "$@" ;; - * ) flags="$flags -$opt" ;; - esac +while getopts "dfiPRrvW" opt; do + case $opt in + f) exec $realrm "$@" ;; + *) flags="$flags -$opt" ;; + esac done -shift $(( OPTIND - 1 )) +shift $((OPTIND - 1)) if [ ! -d "$archive" ]; then - if [ ! -w "$HOME" ]; then - echo "$0 failed: can't create $archive in $HOME" >&2 - exit 1 - fi - mkdir "$archive" - chmod 700 "$archive" + if [ ! -w "$HOME" ]; then + echo "$0 failed: can't create $archive in $HOME" >&2 + exit 1 + fi + mkdir "$archive" + chmod 700 "$archive" fi -for arg -do - newname="$archive/$(date "+%S.%M.%H.%d.%m").$(basename "$arg")" - if [ -f "$arg" ] || [ -d "$arg" ]; then - $copy "$arg" "$newname" - fi +for arg; do + newname="$archive/$(date "+%S.%M.%H.%d.%m").$(basename "$arg")" + if [ -f "$arg" ] || [ -d "$arg" ]; then + $copy "$arg" "$newname" + fi done exec $realrm "$flags" "$@" |