15.62. shebangfix

Possible arguments: (none)

A lot of software uses incorrect locations for script interpreters, most notably /usr/bin/perl and /bin/bash. The shebagngfix macro fixes shebang lines in scripts listed in SHEBANG_FILES. The shebangfix macro is run from ${WRKSRC}, so it can contain paths that are relative to ${WRKSRC}. It can also deal with absolute paths if files outside of ${WRKSRC} require patching. For example:

USES=	shebangfix
SHEBANG_FILES=	scripts/foobar.pl scripts/*.sh

Currently Bash, Java, Ksh, Lua, Perl, PHP, Python, Ruby, Tcl, and Tk are supported by default. To support another interpreter, set SHEBANG_LANG, interp_OLD_CMD and interp_CMD. For example:

SHEBANG_LANG=	lua
lua_OLD_CMD=	/usr/bin/lua
lua_CMD=	${LOCALBASE}/bin/lua

interp_OLD_CMD will contain multiple values. Any entry with spaces must be quoted. For example, if it was not already defined, the Ksh entry could be defined as:

SHEBANG_LANG=	ksh
ksh_OLD_CMD=	"/usr/bin/env ksh" /bin/ksh /usr/bin/ksh
ksh_CMD=	${LOCALBASE}/bin/ksh

Some software uses strange locations for an interpreter. For example, an application might expect Python to be located in /opt/bin/python2.7. The strange path to be replaced can be declared in the port Makefile:

python_OLD_CMD=	/opt/bin/python2.7

注意:

The fixing of shebangs is done during the patch phase. If scripts are created with incorrect shebangs during the build phase, the build process (for examples, the configure script, or the Makefiles) must be patched to generate the right shebangs. Correct paths for supported interpreters are available in interp_CMD.

本文及其他文件,可由此下載: ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/

若有 FreeBSD 方面疑問,請先閱讀 FreeBSD 相關文件,如不能解決的話,再洽詢 <questions@FreeBSD.org>。

關於本文件的問題,請洽詢 <doc@FreeBSD.org>。