mirror of
https://github.com/Snigdha-OS/snigdhaos-system-config.git
synced 2025-12-07 16:43:54 +01:00
38 lines
653 B
Bash
38 lines
653 B
Bash
#!/usr/bin/bash
|
|
set -e
|
|
|
|
EXEC_TERMINAL=bash
|
|
|
|
usage() {
|
|
echo "Usage: ${0##*/} [cmd]"
|
|
echo ' -s [shell] Change shell to [shell]'
|
|
echo ' -h This help'
|
|
exit 1
|
|
}
|
|
|
|
opts='s:h'
|
|
|
|
while getopts "${opts}" arg; do
|
|
case "${arg}" in
|
|
s) EXEC_TERMINAL="$OPTARG" ;;
|
|
h | ?) usage 0 ;;
|
|
*)
|
|
echo "Invalid Argument '${arg}'!"
|
|
usage 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
initfile="$(mktemp)"
|
|
codefile="$initfile"
|
|
echo "#!/usr/bin/env bash" >"$initfile"
|
|
if [ "$EXEC_TERMINAL" != "bash" ]; then
|
|
codefile="$(mktemp)"
|
|
echo "$EXEC_TERMINAL $codefile" >>"$initfile"
|
|
fi
|
|
echo "$1" >>"$codefile"
|
|
chmod +x "$initfile"
|
|
cmd="\"$initfile\""
|