From 40fb312f07ebbdb39fbc6c26c04b0551904f040c Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Fri, 18 Apr 2014 19:49:15 +0200 Subject: [PATCH] Use "type -t" to test for tools. This further enahces commit 2f959f4d and fixes a bug when "__git_ps1" is not available on the system. --- sys/bashrc | 12 ++++++------ sys/profile | 12 +++++------- user/bash_logout | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/sys/bashrc b/sys/bashrc index e3a45dc..33fd599 100644 --- a/sys/bashrc +++ b/sys/bashrc @@ -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" diff --git a/sys/profile b/sys/profile index 6cba9f4..0943d22 100644 --- a/sys/profile +++ b/sys/profile @@ -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- diff --git a/user/bash_logout b/user/bash_logout index 3b25855..c22c8f9 100644 --- a/user/bash_logout +++ b/user/bash_logout @@ -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 -- 2.39.2