termux-packages/packages/termux-tools/login
Leonid Pliushch 5d29da3dc6 termux-tools: do not start login shell if not running on terminal
Fixes execution of commands via non-interactive shell with OpenSSH.
Issue https://github.com/termux/termux-packages/issues/3620.
2019-04-04 12:50:54 +03:00

28 lines
591 B
Bash
Executable File

#!/data/data/com.termux/files/usr/bin/sh
if [ $# = 0 ] && [ -f $PREFIX/etc/motd ] && [ ! -f ~/.hushlogin ]; then
cat $PREFIX/etc/motd
fi
if [ -G ~/.termux/shell ]; then
export SHELL="`realpath ~/.termux/shell`"
else
for file in $PREFIX/bin/bash $PREFIX/bin/sh /system/bin/sh; do
if [ -x $file ]; then
export SHELL=$file
break
fi
done
fi
if [ -f $PREFIX/lib/libtermux-exec.so ]; then
export LD_PRELOAD=$PREFIX/lib/libtermux-exec.so
$SHELL -c "busybox true" > /dev/null 2>&1 || unset LD_PRELOAD
fi
if [ -n "$TERM" ]; then
exec "$SHELL" -l "$@"
else
exec "$SHELL" "$@"
fi