On Mon, 10 Jun 2013, Linda Walsh wrote:
Point taken, but the only way such a string would be passed as a
variable name is if it was given as user input -- which would,
presumably, be sanitized before being used. Programming it literally
makes as much sense as 'rm -rf /'.
---
That still didn't POSIX-Gnu rm from disabling that ability.
Did they? I'm not going to test it :(
Though the one that really causes a pain is them removing
the ability to safely delete all files in a directory with the 'rm' command.
Since when?
Now, many contortions are necessary.
(i.e.: "cd testing/output/ && rm --one-file-system -fr ."
used to safely deleted everything in output -- except the "." --
but it was 'last' (recursive 'rm' has to be depth first), and
the -f would suppress the error you got about not being able to remove ".".
Contortions???
Now they put in a special check to check the starting arguments first,
before doing the depth-first remove and abort any processing for files
in "." You need to use 'find' with alot more typing to do something
similar.
What's wrong with:
rm -rf *
--
Chris F.A. Johnson, <http://cfajohnson.com/>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)