chiark
/
gitweb
/
~cjwatson
/
bin.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a6c1daf
)
pwhich: A portable (I believe) /bin/sh implementation of 'which'.
author
Colin Watson
<cjwatson@chiark.greenend.org.uk>
Mon, 23 Sep 2002 13:31:09 +0000
(13:31 +0000)
committer
Colin Watson
<cjwatson@chiark.greenend.org.uk>
Mon, 23 Sep 2002 13:31:09 +0000
(13:31 +0000)
pwhich
[new file with mode: 0644]
patch
|
blob
diff --git a/pwhich
b/pwhich
new file mode 100644
(file)
index 0000000..
47aa80c
--- /dev/null
+++ b/
pwhich
@@ -0,0
+1,17
@@
+#! /bin/sh -e
+
+RET=1
+for PROGRAM in "$@"; do
+ IFS_SAVE="$IFS"
+ IFS=:
+ for ELEMENT in $PATH; do
+ if [ -f "$ELEMENT/$PROGRAM" -a -x "$ELEMENT/$PROGRAM" ]; then
+ echo "$ELEMENT/$PROGRAM"
+ RET=0
+ break
+ fi
+ done
+ IFS="$IFS_SAVE"
+done
+
+exit "$RET"