Autoconf的文檔建議這個片段的可移植性:解釋這個shell腳本
# Create a temporary directory $tmp in $TMPDIR (default /tmp).
# Use mktemp if possible; otherwise fall back on mkdir,
# with $RANDOM to make collisions less likely.
: ${TMPDIR=/tmp}
{
tmp=`
(umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
` &&
test -n "$tmp" && test -d "$tmp"
} || {
tmp=$TMPDIR/foo$$-$RANDOM
(umask 077 && mkdir "$tmp")
} || exit $?
我不明白的第一行:
爲什麼它有:
開始?
爲什麼在此之後使用TMPDIR
變量?
你可能想看看這個其他[問題和答案](http://stackoverflow.com/questions/7444504/explanation-of-this-use-of-the-colon-operator):) – summea 2013-04-30 18:12:06
@summea謝謝你! – qdii 2013-04-30 18:13:00