]> arthur.barton.de Git - ConfigScripts.git/commitdiff
Use "type -t" to test for tools.
authorAlexander Barton <alex@barton.de>
Fri, 18 Apr 2014 17:49:15 +0000 (19:49 +0200)
committerAlexander Barton <alex@barton.de>
Fri, 18 Apr 2014 17:49:15 +0000 (19:49 +0200)
This further enahces commit 2f959f4d and fixes a bug when "__git_ps1"
is not available on the system.

sys/bashrc
sys/profile
user/bash_logout

index e3a45dc8196db3f71540e596a9a601ed79b3a501..33fd599ef2e05ff113d2db89e74b300fb46c9754 100644 (file)
@@ -13,7 +13,7 @@ BASHRCREAD="true"
 [ "$PS1" ] || return
 
 # Initialize keychain(1) ssh-agent and gpg-agent helper
-type keychain >/dev/null 2>&1 \
+type -t keychain >/dev/null \
        && eval `keychain --agents ssh --eval --quick --quiet`
 
 # Common command aliases (1/2)
@@ -121,7 +121,7 @@ PS1="${PS1}${COLOR_PREPOSTTXT}${PS1_END:->}${COLOR_RESET} "
 [ "$LOGNAME" = "root" ] \
        && PS1="${PS1}${COLOR_PROMPT_ROOT}\\\$${COLOR_RESET} " \
        || PS1="${PS1}${COLOR_PROMPT_USER}\\\$${COLOR_RESET} "
-[ "$(type __git_ps1)" ] \
+type -t __git_ps1 >/dev/null \
        && PS1="\$(__git_ps1 '(${COLOR_VCS}%s${COLOR_RESET}) ')${PS1}"
 PS1="${chroot_name:+[${COLOR_CHROOT}$chroot_name${COLOR_RESET}] }${PS1}"
 PS1="${COLOR_RESET}${PS1}"
@@ -145,7 +145,7 @@ fi
 alias "lasth"="last | head -n \`expr \\\$LINES - 2\`"
 
 # Aliases for screen(1), if installed
-type screen >/dev/null 2>&1
+type -t screen >/dev/null
 if [ $? -eq 0 ]; then
        alias "s"="screen"
        alias "sr"="screen -dr"
@@ -153,16 +153,16 @@ if [ $? -eq 0 ]; then
 fi
 
 # less(1) filter, if available
-type lesspipe >/dev/null 2>&1 \
+type -t lesspipe >/dev/null \
        && eval `lesspipe`
 
 # Setup slrn(1) and cleanscore(1), if installed
-type cleanscore >/dev/null 2>&1 \
+type -t cleanscore >/dev/null \
        && alias slrn="cleanscore -f ~/.slrnscore && slrn"
 
 # Enable color support of ls(1)
 if [ "$TERM" != "dumb" ]; then
-       type dircolors >/dev/null 2>&1 && eval `dircolors -b`
+       type -t dircolors >/dev/null && eval `dircolors -b`
        ls --color / >/dev/null 2>&1
        if [ $? -eq 0 ]; then
                # "GNU style"
index 6cba9f478dfbe47a0847cf84cb147bb7c83ff800..0943d22768eb8d16a50fa942a8ab4ea2fe7865ce 100644 (file)
@@ -84,7 +84,7 @@ unset d
        && PATH=~/sbin:"${PATH}"
 
 # Setup MANPATH, if manpath(1) isn't available
-if [ ! "$(type manpath 2>/dev/null)" ]; then
+if [ ! "$(type -t manpath 2>/dev/null)" ]; then
        [ -z "$MANPATH" ] \
                && MANPATH="/usr/local/share/man:/usr/share/man:/usr/man"
        path=""
@@ -144,7 +144,7 @@ fi
 [ "$PS1" ] || return
 
 # validate terminal definition
-type tset >/dev/null 2>&1 && eval `tset -s -Q`
+type -t tset >/dev/null && eval `tset -s -Q`
 
 # generic shell prompt
 [ "$LOGNAME" = "root" ] \
@@ -154,8 +154,7 @@ type tset >/dev/null 2>&1 && eval `tset -s -Q`
 # Reminders (once every 60 minutes)
 if [ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]; then
        [ -e ~/.ConfigScripts.debug ] && echo " - Reminders ..."
-       type icalBuddy >/dev/null 2>&1
-       if [ $? -eq 0 -a "$LOGNAME" != "root" ]; then
+       if [ "$(type -t icalBuddy >/dev/null)" -a "$LOGNAME" != "root" ]; then
                # icalBuddy(1)
                case "$LANG" in
                        *.UTF*) bul="•"; bul_imp="!"; sep="»"; ;;
@@ -171,8 +170,7 @@ if [ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]; then
                unset bul bul_imp sep
        else
                # remind(1)
-               type remind >/dev/null 2>&1
-               if [ $? -eq 0 -a -r ~/.remind ]; then
+               if [ "$(type -t remind >/dev/null)" -a -r ~/.remind ]; then
                        remind -h -g -t5 ~/.remind | \
                                grep -v '^Reminders for ' | grep -v '^$'
                        [ $? -eq 0 ] && echo
@@ -194,7 +192,7 @@ fi
 # Check filesystem quotas
 mount 2>/dev/null | grep quota >/dev/null 2>&1
 if [ $? -eq 0 ]; then
-       type quota >/dev/null 2>&1 && quota -q
+       type -t quota >/dev/null && quota -q
 fi
 
 # -eof-
index 3b258553e95e4e63b6047906d12f15e9c43c2b81..c22c8f9ba5043838197fd4fafa9b196e8baab0f7 100644 (file)
@@ -16,7 +16,7 @@
 
 # Clean up SSH agents, if running and not using keychain(1)
 if [ $SSH_AGENT_PID ]; then
-       type keychain >/dev/null 2>&1 || eval `ssh-agent -k`
+       type -t keychain >/dev/null || eval `ssh-agent -k`
 fi
 
 # Clear the console if it is a local terminal