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.<div><br></div><div>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.</div>
<div><br></div><div>The code you cite handles a potential circumstance under which the script would most likely blow up by just creating the empty directory. </div><div><br></div><div>That's one circumstance I can think of.</div>
<div><br></div><div><br></div><div>---<br>Jerald M. Sheets jr.<br><br><br>
<br><br><div class="gmail_quote">On Tue, Mar 16, 2010 at 12:24 PM, Dennis Ruzeski <span dir="ltr"><<a href="mailto:denniruz@gmail.com">denniruz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Yet another shell script question-<br>
<br>
I inherited a load of scripts and I'm going through trying to document<br>
them and I ran across this snippet everywhere a directory or file is<br>
created:<br>
<br>
dir=`eval date +%F`<br>
loop="0"<br>
while [ $loop -lt 50 ]<br>
do<br>
if [ -e "/$dir" ]<br>
then<br>
loop="100"<br>
else<br>
mkdir "/$dir"<br>
loop=$((loop+1))<br>
fi<br>
done<br>
<br>
I understand building some robustness into scripts but I've never seen<br>
a mkdir fail in a situation like this. Is this paranoia, best<br>
practice, or somewhere in between?<br>
_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
</blockquote></div><br></div>