Possible arguments: (none)
A lot of software uses incorrect locations for script
interpreters, most notably /usr/bin/perl
and /bin/bash. The shebangfix macro fixes
shebang lines in scripts listed in
SHEBANG_REGEX,
SHEBANG_GLOB, or
SHEBANG_FILES.
SHEBANG_REGEXContains one extended regular
expressions, and is used with the
-iregex argument of find(1). See
Example 17.11, “USES=shebangfix with
SHEBANG_REGEX”.
SHEBANG_GLOBContains a list of patterns used with the
-name argument of find(1). See
Example 17.12, “USES=shebangfix with
SHEBANG_GLOB”.
SHEBANG_FILESContains a list of files or sh(1) globs. The
shebangfix macro is run from ${WRKSRC},
so SHEBANG_FILES can contain paths that
are relative to ${WRKSRC}. It can also
deal with absolute paths if files outside of
${WRKSRC} require patching. See Example 17.13, “USES=shebangfix with
SHEBANG_FILES”.
Currently Bash, Java, Ksh, Lua, Perl, PHP, Python, Ruby, Tcl, and Tk are supported by default.
There are three configuration variables:
SHEBANG_LANGThe list of supported interpreters.
interp_CMDThe path to the command interpreter on FreeBSD. The
default value is
${LOCALBASE}/bin/.interp
interp_OLD_CMDThe list of wrong invocations of interpreters. These
are typically obsolete paths, or paths used on other
operating systems that are incorrect on FreeBSD. They
will be replaced by the correct path in
.interp_CMD
These will always be part of
:
interp_OLD_CMD"/usr/bin/env
.interp"
/bin/interp
/usr/bin/interp
/usr/local/bin/interp
contain multiple values. Any entry with spaces must be
quoted. See Example 17.9, “Specifying all the Paths When Adding an Interpreter to
interp_OLD_CMDUSES=shebangfix”.
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
example, the configure script, or the
Makefiles) must be patched or given the
right path (for example, with
CONFIGURE_ENV,
CONFIGURE_ARGS,
MAKE_ENV, or MAKE_ARGS)
to generate the right shebangs.
Correct paths for supported interpreters
are available in
.interp_CMD
When used with USES=python,
and the aim is only to fix the shebangs but a dependency on
Python itself is not wanted, use
PYTHON_NO_DEPENDS=yes.
USES=shebangfixTo add another interpreter, set
SHEBANG_LANG. For example:
SHEBANG_LANG= lua
USES=shebangfixIf it was not already defined, and there were no default
values for
and interp_OLD_CMD
the Ksh entry could be defined
as:interp_CMD
SHEBANG_LANG= ksh
ksh_OLD_CMD= "/usr/bin/env ksh" /bin/ksh /usr/bin/ksh
ksh_CMD= ${LOCALBASE}/bin/kshSome 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
USES=shebangfix with
SHEBANG_REGEXTo fix all the files in
${WRKSRC}/scripts ending in
.pl, .sh, or
.cgi do:
USES= shebangfix SHEBANG_REGEX= ./scripts/.*\.(sh|pl|cgi)
SHEBANG_REGEX is used by running
find -E, which uses modern regular
expressions also known as extended regular expressions. See
re_format(7) for more information.
USES=shebangfix with
SHEBANG_GLOBTo fix all the files in ${WRKSRC}
ending in .pl or
.sh, do:
USES= shebangfix SHEBANG_GLOB= *.sh *.pl
USES=shebangfix with
SHEBANG_FILESTo fix the files script/foobar.pl and
script/*.sh in
${WRKSRC}, do:
USES= shebangfix SHEBANG_FILES= scripts/foobar.pl scripts/*.sh
All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.