[clug] Ever received a .dat file from an <other OS> user?

Kevin Pulo kev at pulo.com.au
Sat Jan 16 03:01:39 MST 2010


On Sat, Jan 16, 2010 at 11:05:25AM +1100, Peter Barker wrote:

>>>> [ -n "$dir_i_do_not_want" ] && [ -n "$subdir_i_do_not_want" ] && rm -rf
>>>> $dir_i_do_not_want/$subdir_i_do_not_want
>>>
>>> Yes, that certainly a safe way to handle the situation, and what I usually
>>> do.  Somewhat verbose, 'though!
>>
> Really trying to protect against, 'rm -rf  
> "$dr_i_do_not_want/$subdr_i_do_not want"' (cf 'rm -rf  
> "$dir_i_do_not_want/$subdir_i_do_not_want"'), or any one of the related  
> ways to screw yourself over in shell scripting.  Where's my "use strict;"? 
> :-)

In bash, you can do "${dir_i_do_not_want:?Error - dir not
set}/${subdir_i_do_not_want:?Error - subdir not set}", but that's
hardly less verbose and a pain to have to remember to do every time.

I thought there was a shopt or set option which is the equivalent of
"use strict" (and tcsh behaves this way by default when unset
variables are expanded), but I can't seem to find anything for it...
maybe I'm thinking of failglob, which is close but not quite...

Kev.

-- 
.----------------------------------------------------------------------.
| Kevin Pulo                Quidquid latine dictum sit, altum viditur. |
| kev at pulo.com.au               _ll l_ng__g_e_ _r_ hi__ly p__d_ct__le. |
| http://www.kev.pulo.com.au/         God casts the die, not the dice. |
`--------------- Linux: The choice of a GNU generation. ---------------'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/linux/attachments/20100116/959f22c7/attachment.pgp>


More information about the linux mailing list