Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 解释这个shell脚本_Linux_Shell - Fatal编程技术网

Linux 解释这个shell脚本

Linux 解释这个shell脚本,linux,shell,Linux,Shell,Autoconf文档建议使用以下代码段以便于移植: # 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} { t

Autoconf文档建议使用以下代码段以便于移植:

      # 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
变量?

:${TMPDIR=/tmp}表示:

:在bash中为null命令,但如果TMPDIR的内容为null,则shell会将/tmp分配给TMPDIR变量

调用“${TMPDIR=/tmp}”行,该行不执行任何操作,只使用一个参数-结果“${TMPDIR=/tmp}”


如果TMPDIR变量未设置(之前未设置为任何值,甚至为空字符串),则此参数展开会将“/tmp”分配给该变量,然后展开为TMPDIR的值,该值会被“:”builtin.

忽略。您可能需要查看另一个:)