12.7 在 wrapper scripts 中使用 exec 述句

若某 port 為了執行其他程式而安裝了一個 shell script, 而該程式同時也是該 script 最後一個動作,那麼需要確定該 script 是用 exec 述句(statement),舉例而言:

#!/bin/sh
exec %%LOCALBASE%%/bin/java -jar %%DATADIR%%/foo.jar "$@"

exec 述句以所指定的程式取代了該 shell 的程序。 若省略 exec ,那麼該 shell 程序 將會在程式執行中一直存在於記憶體,這無疑地浪費了系統資源。

For questions about the FreeBSD ports system, e-mail <ports@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.