termux-packages/packages/termux-tools/chsh

41 lines
831 B
Plaintext
Raw Normal View History

2015-08-12 02:38:18 +02:00
#!/bin/sh
2015-06-13 01:03:31 +02:00
set -e -u
show_usage () {
2015-08-12 02:38:18 +02:00
echo "usage: chsh [-s shell]"
2015-06-13 01:03:31 +02:00
echo "Change the login shell."
}
set_shell () {
mkdir -p $HOME/.termux
2015-08-12 02:38:18 +02:00
NEW_SHELL=$PREFIX/bin/$1
if test -x $NEW_SHELL -a ! -d $NEW_SHELL; then
2015-06-13 01:03:31 +02:00
ln -f -s $NEW_SHELL $HOME/.termux/shell
else
2015-08-12 02:38:18 +02:00
echo "$NEW_SHELL is not an executable file!"
2015-06-13 01:03:31 +02:00
fi
}
O=`getopt -l help -- hs: "$@"`
eval set -- "$O"
while true; do
case "$1" in
-h|--help) show_usage; exit 0;;
-s) set_shell $2; exit 0;;
--) shift; break;;
*) echo Error; show_usage; exit 1;;
esac
done
2015-08-12 02:38:18 +02:00
DEFAULT_SHELL=bash
if [ ! -x $PREFIX/bin/$DEFAULT_SHELL ]; then DEFAULT_SHELL=ash; fi
echo Changing the login shell
echo Enter the new value, or press ENTER for the default
printf " Login Shell [$DEFAULT_SHELL]: "
read shell
if [ -z "$shell" ]; then shell=$DEFAULT_SHELL; fi
set_shell $shell