以下是來自shell腳本的代碼片段。 (這是從MPFR庫的配置腳本開始的,它以#!/ bin/sh開頭,原始腳本長度超過17000行..用於構建gcc時使用。)關於由autoconf生成的shell腳本的部分問題的許多問題
因爲我在短片中有很多問題代碼,我在代碼中嵌入了我的問題。請有人向我解釋爲什麼代碼是這樣的?另外,雖然我有一個模糊的想法,但是如果有人能夠解釋這段代碼在做什麼(我知道這將是困難的,因爲它只是大腳本的一部分),我將不勝感激。
if { { ac_try="$ac_link"
# <---- question 1 : why is the first curly bracket used for if condition? (probably just for grouping and using the last return code)
# <---- question 2 : Is this second bracket for locally used code(probably)?
case "(($ac_try" in # <---- question 3 : what is this "((" symbol?
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5 # <---- question 4 : what is this >&5 redirection? I know >&{1,2,3} but not 5.
(eval "$ac_link") 2>&5
# <----- question 5 : why use sub-shell here? not to use eval result?
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then : # <---- question 6 : is this ':'(nop) here ?
....
some commands
....
else
....
some commands
....
fi
'configure'腳本不能被讀取。它們是從其他來源生成的。至於你的問題:請刪除所有元評註,其中一個規則是:每個問題一個問題。 – Mat 2015-02-09 06:10:18
墊,我明白。此配置腳本必須來自自動配置,因此變量以ac_ ..開頭。但爲了解決問題,有時我必須查看腳本,並且可以解決問題。所以請耐心等待幾天。只是爲了看到任何答案。它會幫助別人。 – 2015-02-09 06:13:44
閱讀。雖然它不能解釋自動生成的autoconf的特性,這與幾十年來圍繞bug的shell實現有關。 [shell的Posix描述](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html) – rici 2015-02-09 06:14:20