[ale] Why would someone do this?

Dennis Ruzeski denniruz at gmail.com
Tue Mar 16 12:24:37 EDT 2010


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?


More information about the Ale mailing list