When I invoke mktemp in a script as: #!/bin/bash DIR=$( mktemp||exit 1 ) cd $DIR echo $?
I receive an error like: -- can't cd to /tmp/tmp.68rHO2a3jc 2 -- >From a bash-shell I can cd into the temporary dir. But if I in the bash-shell write mkdir -p /tmp/tmp.68rHO2a3jc I get the error: mkdir: cannot create directory `/tmp/tmp.UrC5wV58SC': File exists despite of the -p flag. My primitive workaround is to recreate $DIR as in: #!/bin/bash DIR=$( mktemp||exit 1 ) rm -r -f $DIR mkdir -p $DIR cd $DIR echo $? And in this case the "mkdir -p" recreation, from a bash-shell, does not give any errors
