.bashrc.d/20nobeep: Style and POSIX cleanups
authorW. Trevor King <wking@tremily.us>
Mon, 4 Mar 2013 06:15:18 +0000 (01:15 -0500)
committerW. Trevor King <wking@tremily.us>
Mon, 4 Mar 2013 06:15:18 +0000 (01:15 -0500)
* `which` is not in POSIX 2008, use `command -v` instead.
* Avoid the temporary XSET variable.
* Reorganize to consolidate if statements.

src/.bashrc.d/20nobeep

index 50fc3ec43e511b13b59b73ae835f6f4cf551cc63..a887db63f55fd586b77772c2a18c00617e518cb1 100644 (file)
@@ -1,15 +1,11 @@
 # turn off terminal beep in X
-if [ $TERM == "xterm" ] && [ -n "$DISPLAY" ]; then
-       XSET=$(which xset 2> /dev/null)
-       if [ -n "${XSET}" ]; then
+if [ -n "$DISPLAY" ] && [ "$TERM" == "xterm" ]; then
+       if [ -x "$(command -v xset)" ]; then
                xset b off
        fi;
-       unset XSET
 fi
 
 # turn of terminal beeps in the console, unless connecting via SSH
-if [ -z "$SSH_CLIENT" ]; then
-       if [ ! -z "$TERM" ]; then
-               setterm -blength 0
-       fi
+if [ -n "$TERM" ] && [ -z "$SSH_CLIENT" ]; then
+       setterm -blength 0
 fi