[ale] Why would someone do this?

Dennis Ruzeski denniruz at gmail.com
Tue Mar 16 20:07:06 EDT 2010


It's not actually in the root directory- I removed the full path.

This is basically a backup script that timestamps a mysql dump all on
local disk.

--Dennis





On Tue, Mar 16, 2010 at 6:45 PM, David Tomaschik <david at tuxteam.com> wrote:
> 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]
>
>
>
> _______________________________________________
> 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
>
>



More information about the Ale mailing list