Path: utzoo!mnetor!uunet!husc6!bbn!mit-eddie!uw-beaver!ssc-vax!uvicctr!tholm From: tholm@uvicctr.UUCP (Terrence W. Holm) Newsgroups: comp.os.minix Subject: which(1) Message-ID: <400@uvicctr.UUCP> Date: 5 May 88 06:53:03 GMT Reply-To: tholm@uvicctr.UUCP (Terrence W. Holm) Organization: University of Victoria, Victoria B.C. Canada Lines: 113 EFTH Minix report #7 - May 1988 - which(1) This is an implementation of which(1) that we wrote for Minix. Please consider this a public domain program. E. Baalbergen's test(1) program was modified to support the "-x" option. The fix is included. "man" pages are also included. echo x - which gres '^X' '' > which << '/' X#!/bin/sh X# which(1) efth 1988-Apr-14 X Xif test $# -ne 1; then X echo "Usage: which program" X exit 1 X fi X Xpath="`IFS=: eval echo $PATH`" X Xfor dir in . $path; do X filename=$dir/$1 X if test -f $filename -a -x $filename; then X echo $filename X exit 0 X fi X done X Xecho "No $1 in . $path" Xexit 1 / echo x - which.1 gres '^X' '' > which.1 << '/' XNAME X which(1) - which program will I get X XSYNOPSIS X which program X XDESCRIPTION X All of the directories in the current search path ($PATH) X are scanned for "program". The first occurrence is reported. X XSEE ALSO X whereis(1) X XBUGS X The current directory "." is always scanned first. / echo x - test.fix gres '^X' '' > test.fix << '/' X1a2,4 X> X> /* Added "-x" option 1988-Apr-17 efth */ X> X14c17 X< unary-operator ::= "-r"|"-w"|"-f"|"-d"|"-s"|"-t"|"-z"|"-n"; X--- X> unary-operator ::= "-r"|"-w"|"-x"|"-f"|"-d"|"-s"|"-t"|"-z"|"-n"; X41a45 X> #define FILEX 23 X54a59 X> {"-x", FILEX, UNOP}, X182a188,189 X> case FILEX: X> return access(nm, 1) == 0; / echo x - test.1 gres '^X' '' > test.1 << '/' XNAME X test(1) - test for a condition X XSYNOPSIS X test expr X XDESCRIPTION X Test checks to see if files exist, are readable, etc. and returns X an exit status of zero if true and nonzero if false. The legal X operators are: X X -r file true if the file is readable X -w file true if the file is writable X -x file true if the file is executable X -f file true if the file is not a directory X -d file true if the file is a directory X -s file true if the file exists and has a size > 0 X -t fd true if file descriptor fd (default 1) is a terminal X -z s true if the string s has zero length X -n s true if the string s has nonzero length X s1 = s2 true if the strings s1 and s2 are identical X s1 != s2 true if the strings s1 and s2 are different X m -eq m true if the integers m and n are numerically equal X The operators -gt, -ge, -ne, -le, -lt may be used as well X X These operands may be combined with -a (Boolean and), -o (Boolean or), X ! (negation). The priority of -a is higher than that of -o. X Parentheses are permitted, but must be escaped to keep the shell from X trying to interpret them. X XEXAMPLE X test -r file # see if file is readable / -------------------------------------------------------------------- Edwin L. Froese uw-beaver!ubc-vision!mprg!handel!froese Terrence W. Holm uw-beaver!uvicctr!sirius!tholm