Cleanup command substitution styles.

This commit is contained in:
David Tomaschik
2019-11-12 17:19:10 -08:00
parent 2419693164
commit 288a9c3a7e

View File

@@ -29,14 +29,14 @@ prerequisites() {
if which zsh > /dev/null 2>&1 ; then if which zsh > /dev/null 2>&1 ; then
case $- in case $- in
*i*) *i*)
case `getent passwd $USER | cut -d: -f7` in case $(getent passwd $USER | cut -d: -f7) in
*/zsh) */zsh)
;; ;;
*) *)
if [ `id` -ne 0 ] ; then if [ $(id) -ne 0 ] ; then
echo 'Enter password to change shell.' >&2 echo 'Enter password to change shell.' >&2
fi fi
chsh -s `which zsh` chsh -s $(which zsh)
;; ;;
esac esac
;; ;;
@@ -91,7 +91,7 @@ install_basic_dir() {
find "${SRCDIR}" ${FINDTYPE} f -print | \ find "${SRCDIR}" ${FINDTYPE} f -print | \
while read file ; do while read file ; do
local TARGET="${2}/${file#${SRCDIR}/}" local TARGET="${2}/${file#${SRCDIR}/}"
mkdir -p `dirname "${TARGET}"` mkdir -p $(dirname "${TARGET}")
ln -s -f "${file}" "${TARGET}" ln -s -f "${file}" "${TARGET}"
done done
} }
@@ -116,7 +116,7 @@ install_git() {
} }
add_bin_symlink() { add_bin_symlink() {
local LINKNAME=${HOME}/bin/${2:-`basename $1`} local LINKNAME=${HOME}/bin/${2:-$(basename $1)}
if [ -e ${LINKNAME} -a ! -h ${LINKNAME} ] ; then if [ -e ${LINKNAME} -a ! -h ${LINKNAME} ] ; then
echo "Refusing to overwrite ${LINKNAME}" >&2 echo "Refusing to overwrite ${LINKNAME}" >&2
return 1 return 1
@@ -134,15 +134,15 @@ ssh_key_already_installed() {
if [ ! -f $AK ] ; then if [ ! -f $AK ] ; then
return 1 return 1
fi fi
local KEYFP=`ssh-keygen -l -f $1 2>/dev/null | awk '{print $2}'` local KEYFP=$(ssh-keygen -l -f $1 2>/dev/null | awk '{print $2}')
local TMPF=`mktemp` local TMPF=$(mktemp)
local key local key
while read key ; do while read key ; do
if is_comment "${key}" ; then if is_comment "${key}" ; then
continue continue
fi 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
@@ -168,10 +168,10 @@ install_ssh_keys() {
continue continue
fi fi
if ssh_key_already_installed "${key}" ; then if ssh_key_already_installed "${key}" ; then
verbose "Key `basename ${key}` already installed..." verbose "Key $(basename ${key}) already installed..."
continue continue
fi fi
echo "# `basename ${key}` added from skel on `date +%Y-%m-%d`" >> ${AK} echo "# $(basename ${key}) added from skel on $(date +%Y-%m-%d)" >> ${AK}
cat ${key} >> ${AK} cat ${key} >> ${AK}
done done
} }
@@ -192,7 +192,7 @@ install_known_hosts() {
fi fi
mkdir -p ${HOME}/.ssh mkdir -p ${HOME}/.ssh
if [ -f "${HOME}/.ssh/known_hosts" ] ; then if [ -f "${HOME}/.ssh/known_hosts" ] ; then
local tmpf=`mktemp` local tmpf=$(mktemp)
cat ${BASEDIR}/keys/known_hosts ${HOME}/.ssh/known_hosts | sort -u > $tmpf cat ${BASEDIR}/keys/known_hosts ${HOME}/.ssh/known_hosts | sort -u > $tmpf
mv $tmpf ${HOME}/.ssh/known_hosts mv $tmpf ${HOME}/.ssh/known_hosts
else else
@@ -264,8 +264,8 @@ install_apt_pkgs() {
} }
install_chrome() { install_chrome() {
local TMPD=`mktemp -d` local TMPD=$(mktemp -d)
local CHROME_ARCH=`echo ${ARCH} | sed 's/x86_64/amd64/'` local CHROME_ARCH=$(echo ${ARCH} | sed 's/x86_64/amd64/')
dpkg-query -l 'google-chrome*' >/dev/null 2>&1 && return 0 dpkg-query -l 'google-chrome*' >/dev/null 2>&1 && return 0
/usr/bin/wget --quiet -O ${TMPD}/google-chrome.deb \ /usr/bin/wget --quiet -O ${TMPD}/google-chrome.deb \
https://dl.google.com/linux/direct/google-chrome-beta_current_${CHROME_ARCH}.deb https://dl.google.com/linux/direct/google-chrome-beta_current_${CHROME_ARCH}.deb
@@ -277,8 +277,8 @@ install_chrome() {
read_saved_prefs() { read_saved_prefs() {
# Can't use basedir here as we don't have it yet # Can't use basedir here as we don't have it yet
local old_pref_file=`dirname $0`/installed-prefs local old_pref_file=$(dirname $0)/installed-prefs
local pref_file=`dirname $0`/.installed-prefs local pref_file=$(dirname $0)/.installed-prefs
if [ -f ${old_pref_file} -a ! -f ${pref_file} ] ; then if [ -f ${old_pref_file} -a ! -f ${pref_file} ] ; then
mv ${old_pref_file} ${pref_file} mv ${old_pref_file} ${pref_file}
fi fi