Final bashism cleanup.

This commit is contained in:
David Tomaschik
2018-01-30 19:25:47 -08:00
parent 696cc9c6cd
commit 7c5a617897

View File

@@ -16,15 +16,30 @@ case $(uname) in
;; ;;
esac esac
is_comment() {
if [ $(echo "${1}" | cut -c1-1) = '#' ] ; then
true
else
false
fi
}
prerequisites() { prerequisites() {
if which zsh > /dev/null 2>&1 ; then if which zsh > /dev/null 2>&1 ; then
if [[ $- = *i* ]] ; then case $- in
if [[ `getent passwd $USER | cut -d: -f7` != */zsh ]] ; then *i*)
case `getent passwd $USER | cut -d: -f7` in
*/zsh)
;;
*)
if [ `id` -ne 0 ] ; then
echo 'Enter password to change shell.' >&2 echo 'Enter password to change shell.' >&2
fi
chsh -s `which zsh` chsh -s `which zsh`
fi ;;
fi esac
;;
esac
install_git https://github.com/robbyrussell/oh-my-zsh.git $HOME/.oh-my-zsh install_git https://github.com/robbyrussell/oh-my-zsh.git $HOME/.oh-my-zsh
else else
echo "ZSH not found!" >&2 echo "ZSH not found!" >&2
@@ -135,13 +150,16 @@ ssh_key_already_installed() {
local TMPF=`mktemp` local TMPF=`mktemp`
local key local key
while read key ; do while read key ; do
if is_comment "${key}" ; then
continue
fi
echo "$key" > $TMPF echo "$key" > $TMPF
local EFP=`ssh-keygen -l -f ${TMPF} 2>/dev/null | awk '{print $2}'` local EFP=`ssh-keygen -l -f ${TMPF} 2>/dev/null | awk '{print $2}'`
if [ "$EFP" = "$KEYFP" ] ; then if [ "$EFP" = "$KEYFP" ] ; then
rm $TMPF 2>/dev/null rm $TMPF 2>/dev/null
return 0 return 0
fi fi
done < <(grep -v '^#' ${AK}) done < ${AK}
rm $TMPF 2>/dev/null rm $TMPF 2>/dev/null
return 1 return 1
} }
@@ -220,7 +238,7 @@ install_pkg_set() {
local pkg_list="" local pkg_list=""
if [ ! -f "${pkg_file}" ] ; then return 0 ; fi if [ ! -f "${pkg_file}" ] ; then return 0 ; fi
while read line ; do while read line ; do
if [ $(echo "${line}" | cut -c1-1) = '#' ] ; then if is_comment "${line}" ; then
continue continue
fi fi
if [ -z "${line}" ] ; then if [ -z "${line}" ] ; then
@@ -286,7 +304,8 @@ save_prefs() {
} }
echo_pref() { echo_pref() {
echo "$1=\${$1:-${!1}}" eval "local val=\${$1}"
echo "$1=\${$1:-${val}}"
} }
cleanup() { cleanup() {
@@ -369,6 +388,10 @@ case $OPERATION in
pwndbg) pwndbg)
install_pwndbg install_pwndbg
;; ;;
test)
# Do nothing, just sourcing
set +o errexit
;;
*) *)
echo "Unknown operation $OPERATION." >/dev/stderr echo "Unknown operation $OPERATION." >/dev/stderr
exit 1 exit 1