termux-packages/packages/termux-tools/termux-fix-shebang
Leonid Pliushch ccb9ab922a termux-tools: use @TERMUX_PREFIX@ instead of path in sources
Ensure that scripts always use correct prefix-specific path.
2019-09-20 00:16:26 +03:00

13 lines
370 B
Bash
Executable File

#!/bin/sh
if [ $# = 0 -o "$1" = "-h" ]; then
echo 'usage: termux-fix-shebang <files>'
echo 'Rewrite shebangs in specified files for running under Termux,'
echo 'which is done by rewriting #!*/bin/binary to #!@TERMUX_PREFIX@/bin/binary.'
exit 1
fi
for file in "$@"; do
sed -i -E "1 s@^#\!(.*)/[sx]?bin/(.*)@#\!@TERMUX_PREFIX@/bin/\2@" "$(realpath "${file}")"
done