texlive: update to 2018 and update poppler patches to work with 0.64
[termux-packages] / packages / termux-tools / chsh
CommitLineData
da9d8578 1#!/bin/sh
59f0d218
FF
2
3set -e -u
4
59f0d218 5show_usage () {
da9d8578 6 echo "usage: chsh [-s shell]"
59f0d218
FF
7 echo "Change the login shell."
8}
9
10set_shell () {
2d361664
FF
11 if [ "$1" = login ]; then
12 echo "login is not a valid shell"
13 exit 1
14 fi
59f0d218 15 mkdir -p $HOME/.termux
da9d8578
FF
16 NEW_SHELL=$PREFIX/bin/$1
17 if test -x $NEW_SHELL -a ! -d $NEW_SHELL; then
59f0d218
FF
18 ln -f -s $NEW_SHELL $HOME/.termux/shell
19 else
da9d8578 20 echo "$NEW_SHELL is not an executable file!"
59f0d218
FF
21 fi
22}
23
24O=`getopt -l help -- hs: "$@"`
25eval set -- "$O"
26while true; do
27 case "$1" in
28 -h|--help) show_usage; exit 0;;
29 -s) set_shell $2; exit 0;;
30 --) shift; break;;
31 *) echo Error; show_usage; exit 1;;
32 esac
33done
34
da9d8578
FF
35DEFAULT_SHELL=bash
36if [ ! -x $PREFIX/bin/$DEFAULT_SHELL ]; then DEFAULT_SHELL=ash; fi
37
38echo Changing the login shell
39echo Enter the new value, or press ENTER for the default
40printf " Login Shell [$DEFAULT_SHELL]: "
41read shell
42
43if [ -z "$shell" ]; then shell=$DEFAULT_SHELL; fi
44set_shell $shell