One thought occurs to me: if you got $dir from the user and forgot to chomp it, you'll have a trailing EOL in it. The `mkdir -p $dir` won't care about it, but -d $dir might. (I've not tested it, so I'm not certain.) If that's the case, then -d would report that the directory "foo\n" doesn't exist even when "foo" does, causing mkdir to run each time you execute your code.
...roboticusIn reply to Re: problem in checking if directory exists
by roboticus
in thread problem in checking if directory exists
by denzil_cactus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |