[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RE: undelete



On Tue, Jan 23, 2007 at 04:46:17PM -0500, Angelo Bertolli wrote:
> 
> #!/bin/bash
> 
> mv $@ ~/.Trash
> 
Hmm.  There are some problems here:

roberto@miami:~$ which rm
/home/roberto/bin/rm
roberto@miami:~$ touch test
roberto@miami:~$ rm test 
roberto@miami:~$ ls .Trash/
test
roberto@miami:~$ touch test
roberto@miami:~$ rm test 
mv: overwrite `/home/roberto/.Trash/test'? y
roberto@miami:~$ touch test
roberto@miami:~$ rm -f test 
roberto@miami:~$ ls .Trash/
test
roberto@miami:~$ mkdir testdir
roberto@miami:~$ touch testdir/test
roberto@miami:~$ rm -r testdir/
mv: invalid option -- r
Try `mv --help' for more information.
roberto@miami:~$ touch test2
roberto@miami:~$ rm -- test2
roberto@miami:~$ ls .Trash/
test  test2

I'd say it needs some more smarts.

> exit 0
> 
This is universally bad.  You are declaring here that no matter the exit
code of the mv command, this script will exit successfully.  You should
generally exit with something like $? to make sure that the exit code
gets passed to the calling shell.

Regards,

-Roberto

-- 
Roberto C. Sanchez
http://people.connexer.com/~roberto
http://www.connexer.com

Attachment: signature.asc
Description: Digital signature


Reply to: