From 931df3e02285c84e0c5bc66f2bd8daf8b5f9ec44 Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Wed, 14 Jan 2009 22:15:09 -0500 Subject: [PATCH] clean up some syntax --- commonsh/02_term | 9 ++++----- commonsh/10_alias | 33 +++++++++++---------------------- commonsh/10_pager | 2 +- commonsh/10_rlwrap | 2 +- lock | 2 +- 5 files changed, 18 insertions(+), 30 deletions(-) diff --git a/commonsh/02_term b/commonsh/02_term index 29cf243..a38335a 100755 --- a/commonsh/02_term +++ b/commonsh/02_term @@ -3,7 +3,7 @@ # terminal fallback stuff fix_term () { - if (infocmp $1 > /dev/null 2>&1) ; then + if ( infocmp $1 >/dev/null 2>&1 ) ; then echo $1 else case $1 in @@ -20,7 +20,7 @@ fix_term () fix_term screen-256colors ;; screen-256colors) - if (infocmp xterm-256colors &> /dev/null) ; then + if ( infocmp xterm-256colors >/dev/null 2>&1 ) ; then fix_term xterm-256colors else fix_term screen @@ -65,7 +65,7 @@ TERM=`fix_term $TERM` # I am sorry to hear that you are running an # xterm that has no colors (I am looking at you solaris) -if [ $TERM = xterm ] && (command -v tput > /dev/null 2>&1) && [ `tput -T xterm colors` = -1 ] ; then +if [ $TERM = xterm ] && ( command -v tput >/dev/null 2>&1 ) && [ `tput -T xterm colors` = -1 ] ; then # lets see what we can do about your terrible term TERM=`fix_term xterm-color` fi @@ -74,7 +74,6 @@ export TERM case $TERM in *256*) - SCREEN_TERM=$(fix_term screen-256color-bce) - alias screen="screen -T ${SCREEN_TERM}" + alias screen="screen -T `fix_term screen-256color-bce`" ;; esac diff --git a/commonsh/10_alias b/commonsh/10_alias index a915598..9484b24 100755 --- a/commonsh/10_alias +++ b/commonsh/10_alias @@ -1,7 +1,7 @@ #! /bin/sh # colors for dircolors in gdircolors dircolors ; do - if (command -v $dircolors > /dev/null 2>&1) ; then + if ( command -v $dircolors >/dev/null 2>&1) ; then [ -f "${HOME}/.dir_colors" ] && eval `$dircolors -b "${HOME}/.dir_colors"` && break [ -f /etc/DIR_COLORS ] && eval `$dircolors -b /etc/DIR_COLORS` && break eval `$dircolors -b` && break @@ -10,7 +10,7 @@ done # gimmie an editor, make it a nice vi clone for EDITOR in vim elvis vile nvi vi ; do - (command -v $EDITOR > /dev/null 2>&1) && break + ( command -v $EDITOR >/dev/null 2>&1 ) && break done export EDITOR @@ -37,33 +37,22 @@ case `uname -s` in alias ls="ls --color" ;; SunOS) - if (command -v gls > /dev/null 2>&1) ; then + if ( command -v gls >/dev/null 2>&1 ) ; then alias ls="gls -h --color=auto" + elif ( ls --version 2>/dev/null | grep GNU >/dev/null 2>&1 ) ; then + alias ls="ls -h --color=auto" else - # you have a GNU ls, surprise... - case `ls --version 2>/dev/null | head -n 1` in - *fileutils*|*coreutils*) - alias ls="ls -h --color=auto" - ;; - *) - alias ls="ls -h" - ;; - esac + alias ls="ls -h" fi - if (command -v ggrep > /dev/null 2>&1) ; then + if ( command -v ggrep >/dev/null 2>&1 ) ; then alias grep='ggrep -d skip --color=auto' - else - # woah, you have a GNU grep... - case `grep --version 2>/dev/null | head -n 1` in - *GNU*) - alias grep='grep -d skip --color=auto' - ;; - esac + elif ( grep --version 2>/dev/null | grep GNU >/dev/null 2>&1 ) ; then + alias grep='grep -d skip --color=auto' fi for locate in glocate slocate ; do - (command -v $locate > /dev/null 2>&1) && alias locate=$locate + ( command -v $locate >/dev/null 2>&1 ) && alias locate=$locate done ;; esac @@ -73,4 +62,4 @@ alias du='du -h' alias ping='ping -c4' -(command -v time > /dev/null 2>&1) && alias time='command time' +( command -v time >/dev/null 2>&1 ) && alias time='command time' diff --git a/commonsh/10_pager b/commonsh/10_pager index c33adfb..17cd3f5 100755 --- a/commonsh/10_pager +++ b/commonsh/10_pager @@ -1,5 +1,5 @@ for PAGER in less more pg ; do - (command -v $PAGER > /dev/null 2>&1) && break + ( command -v $PAGER >/dev/null 2>&1 ) && break done export PAGER diff --git a/commonsh/10_rlwrap b/commonsh/10_rlwrap index 7627bac..1314fff 100755 --- a/commonsh/10_rlwrap +++ b/commonsh/10_rlwrap @@ -1,4 +1,4 @@ #! /bin/sh for wrap in rlwrap rlfe cle ; do - (command -v $wrap > /dev/null 2>&1) && alias ocaml="$wrap ocaml" && break + ( command -v $wrap >/dev/null 2>&1 ) && alias ocaml="$wrap ocaml" && break done diff --git a/lock b/lock index 0f12cf4..75b1d2a 100755 --- a/lock +++ b/lock @@ -1,6 +1,6 @@ #! /bin/sh -if [[ `uname -s` = 'Darwin' ]] ; then +if [ `uname -s` = 'Darwin' ] ; then /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine exit fi