[ale] Why would someone do this?

David Tomaschik david at tuxteam.com
Tue Mar 16 18:45:05 EDT 2010


Why would they do that?  I honestly have no idea.  For one, they're
creating a directory in the root dir, but that's not the issue I see
here.  For one, they should use the "-d" test to make sure "/$dir" is a
directory.  Secondly, the ONLY case I can think of where I would want to
try more than once to create a directory is if the parent is on some
sort of network directory (e.g., NFS) that might be unreachable at some
point.  Of course, in that case, I'd probably want to put a small delay
in there somewhere.

IMO, this falls into the category of "paranoia that actually doesn't
make things any better."  Is there any context to this code?


Dennis Ruzeski wrote:
> Yet another shell script question-
>
> I inherited a load of scripts and I'm going through trying to document
> them and I ran across this snippet everywhere a directory or file is
> created:
>
> dir=`eval date +%F`
> loop="0"
> while [ $loop -lt 50 ]
>         do
>                 if [ -e "/$dir" ]
>                         then
>                                 loop="100"
>                         else
>                                 mkdir "/$dir"
>                                 loop=$((loop+1))
>                 fi
>         done
>
> I understand building some robustness into scripts but I've never seen
> a mkdir fail in a situation like this. Is this paranoia, best
> practice, or somewhere in between?
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>   


-- 
David Tomaschik, RHCE
Moderator, LinuxQuestions.org
http://www.tuxteam.com
david at tuxteam.com [GPG: 0x6D428695]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 898 bytes
Desc: OpenPGP digital signature
Url : http://mail.ale.org/pipermail/ale/attachments/20100316/2bf2b5e5/attachment.bin 


More information about the Ale mailing list