Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!sun-barr!newstop!grapevine!sun!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.unix.questions Subject: Re: which/type & built-ins Message-ID: <1301@quintus.UUCP> Date: 3 Jan 90 00:02:48 GMT References: <1297@quintus.UUCP> <1990Jan2.160927.11935@usenet.ins.cwru.edu> Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 38 In article <1990Jan2.160927.11935@usenet.ins.cwru.edu> chet@po.CWRU.Edu writes: >In article <1297@quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes: >>...[in Bourne shell]... So why does "type while" say "while not found" >>rather than "while is a shell builtin"? >Because `while' is a sh language construct (a statement), not a shell >builtin. Yes, I *KNOW* that. That's an excellent argument for having "type while" say "while is a keyword" rather than "while is a shell builtin". It is *NOT* an argument for having "type while" say "while not found". Given the wording of the manual page, and a few seconds thought about what would be useful, it seems most natural to interpret the response "XXX not found" as meaning "a command cannot currently begin with the word XXX, so you can use XXX as the name of a new command without interfering with anything". That is, in fact, what I wanted to use 'type' and 'which' for. I often make up little shell scripts, and I get so tired of calling them all 'zabbo' and then forgetting what they do. I would like to put together a command "howabout X" which tells me if X is "free" in both the Bourne shell and the C shell, and the obvious way to do that is to check the output of both 'which $X' and 'sh -c "type $X"'. It looks as though the best I can do is to do that and then filter out keywords myself, which means that I have to adapt "howabout" myself for every UNIX system I deal with... Recommendation: it would be a Good Thing if "which X" said #Cshell builtin X # when X is a C-shell built-in command #Cshell keyword X # when X is part of a C-shell control structure and "type X" said X is a keyword # when X is part of a control structure so that no X in $PATH # which X not found # type would mean that X was not currently in use as the first word of a possible command.