chiark / gitweb /
bash_profile: Split check-for-program code into its own function.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 13 Feb 2007 23:56:38 +0000 (23:56 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 13 Feb 2007 23:56:38 +0000 (23:56 +0000)
I'll want this later on.

bash_profile

index 22931b0de487c285dbe67655887352477e3db7a7..287f3cbed2f5fc1a2ebe3b557102d55f6f198d0a 100644 (file)
@@ -80,6 +80,10 @@ if [ -d /usr/local/plan9 ]; then
     $PLAN9/bin
 fi
 
     $PLAN9/bin
 fi
 
+# --- Find whether a program exists ---
+
+__mdw_programp () { type -t >/dev/null "$1"; }
+
 # --- And the same for manual pages ---
 
 case "$MACHTIME" in
 # --- And the same for manual pages ---
 
 case "$MACHTIME" in
@@ -103,7 +107,7 @@ export QMAILINJECT=c
 export EDITOR=ed
 for ed in "emacs21 -nw" "emacs -nw" vi pico nano ae; do
   name=`echo $ed | sed 's/ .*$//'`
 export EDITOR=ed
 for ed in "emacs21 -nw" "emacs -nw" vi pico nano ae; do
   name=`echo $ed | sed 's/ .*$//'`
-  if type -t >/dev/null "$name"; then
+  if __mdw_programp "$name"; then
     EDITOR=$ed
     break
   fi
     EDITOR=$ed
     break
   fi