[ale] Why would someone do this?
Jerald Sheets
questy at gmail.com
Tue Mar 16 13:17:34 EDT 2010
I have cases from time to time where I rely on a directory being there from
another script that is supposed to run at a predetermined time. An instance
like what you cite would run after.
Let's say, for instance, I create a directory location if a certain thing
occurs. Now let's say that for every X things that occur, I create a
directory for each one. Now, let's say that for today, in a totally
acceptable circumstance, X-1 things occur, leaving the directory
non-existent.
The code you cite handles a potential circumstance under which the script
would most likely blow up by just creating the empty directory.
That's one circumstance I can think of.
---
Jerald M. Sheets jr.
On Tue, Mar 16, 2010 at 12:24 PM, Dennis Ruzeski <denniruz at gmail.com> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20100316/c1bbf42e/attachment.html
More information about the Ale
mailing list