Dan Widyono on 1 Feb 2006 18:52:17 -0000


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

Re: [PLUG] Interactive rm


In addition to Mark's analysis, recent bash shells also change their
behaviour depending on if a glob actually expands to anything.  Using
failglob or nullglob variables, this will really set your hair on end trying
to determine what the shell will transfer to your script.

The safest way to change the shell's behaviour (and therefore rm's) is to
change the shell's programming, because you then are certain you have access
to the raw command line 100% of the time, and then you can determine if any
glob characters were input in any of the arguments.  You could also go hog
wild and 'set -f' in your .bashrc, thus disabling all globbing.  But that's
going back to the Stone Ages.

I would not recommend allowing different behaviour that's dependent on the
type of argument(s).  Talk about a crazy API that will surprise the most
seasoned unix user.

Dan W.

P.S.  To be precise, the original post mentioned: when a specific non-glob
path is provided, do 'rm -f'.  When a glob path is provided, do 'rm -i'.
That might not have been his true intention, but it makes for a more
interesting exercise.  Have at it.
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug