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