diff --git a/trash b/trash index 346b27a..cc3a2cb 100755 --- a/trash +++ b/trash @@ -15,7 +15,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -version="0.3.4 \$Id: trash 2011/03/17 14:56:07 GMT rr@dwaible $" +version="0.3.6 \$Id: trash 2011/03/17 15:03:22 GMT rr@dwaible $" function show_usage { cat << EOU @@ -28,6 +28,8 @@ Options: -h, --help show this help message and exit -v, --verbose explain what is being done -i, --interactive prompt before moving every file + -r, -R, --recursive ignored (for compatability with rm) + -f, --force ignore non-existent files, never prompt EOU } @@ -38,7 +40,7 @@ function try_help { # Option handling -if ! options=$(getopt -o hvi -l "help,verbose,interactive::,version" -n "$0" -- $@) +if ! options=$(getopt -o hvirRf -l "help,verbose,interactive::,version,recursive,force" -n "$0" -- $@) then exit 1 fi @@ -72,7 +74,9 @@ case $1 in fi interactive=$arg ;; - --version) echo "$0 $version" 1>&2;; + --version) echo "$0 $version" 1>&2 ;; + -r|-R|--recursive) ;; + -f|--force) interactive=force ;; (--) shift; break;; (-*) echo "$0: invalid option -- '$1'" 1>&2 ; try_help ; exit 1 ;; (*) break;; @@ -170,9 +174,10 @@ function can_trash { filename=$1 if [ ! -e "$filename" ]; then - echo "$0: cannot move \`$filename' to trash: No such file or directory" 1>&2 + if [ "$interactive" != "force" ]; then + echo "$0: cannot move \`$filename' to trash: No such file or directory" 1>&2 + fi echo 0 - else type="file" @@ -181,7 +186,7 @@ function can_trash { fi case $interactive in - never) echo 1 ;; + never|force) echo 1 ;; always) read -p "$0: move ${type} '${filename}' to trash?" yn if [[ "$yn" =~ ^[yY]$ ]]; then