C shell scripts (was: Re: which(1), rewritten in C?)

2000-03-03 Thread Patrick M. Hausen

Hi all!

 On Thu, Mar 02, 2000 at 08:47:19PM -0500, Dan Papasian wrote:
  While this may sound crazy, I was tired of 'which' taking a long
  time to complete on my 486 dx4/100 when it was under extereme
  pressure, so I rewrote it in C :)
  
  I don't think that it is worthwhile replacing this perl script
  with one written in C, but if anyone is interested...
 
 Why in the world isn't ``which'' written as a csh shell script??

Most probably because C shell scripts should be avoided at any
cost.

See: http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

Regards,
Patrick
-- 
WEB Internet Services Systemhaus GmbH   Scheffelstr. 17a76135 Karlsruhe
 phone +49 721 9109 0   fax +49 721 9109 100   http://www.punkt.de/
   Patrick M. Hausen   Technical Director   email [EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: C shell scripts (was: Re: which(1), rewritten in C?)

2000-03-03 Thread David O'Brien

On Fri, Mar 03, 2000 at 10:09:17AM +0100, Patrick M. Hausen wrote:
 Most probably because C shell scripts should be avoided at any
 cost.
 
 See: http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

I do know about this FAQ, however for a very simple script that is just
passing arguments to a built-in function.
 
-- 
-- David([EMAIL PROTECTED])


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: C shell scripts (was: Re: which(1), rewritten in C?)

2000-03-03 Thread Assar Westerlund

"David O'Brien" [EMAIL PROTECTED] writes:
 I do know about this FAQ, however for a very simple script that is just
 passing arguments to a built-in function.

There's a real reason for not writing this in csh.  Because the
built-in function will return results for csh, which might not be the
right ones for other shells.

What result do you get with `which which' for example?

/assar


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: C shell scripts (was: Re: which(1), rewritten in C?)

2000-03-03 Thread Assar Westerlund

Garrett Wollman [EMAIL PROTECTED] writes:
 The error is in using `which' with another shell.  The correct command
 to use with POSIX-ish shells (sh, ksh, bash, etc.) is `type'.

Sure, but there's a /usr/bin/which program.  Do you suggest we should
remove it?  I don't have any problems with that...

/assar


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: C shell scripts (was: Re: which(1), rewritten in C?)

2000-03-03 Thread Garrett Wollman

On 03 Mar 2000 17:03:05 +0100, Assar Westerlund [EMAIL PROTECTED] said:

 Sure, but there's a /usr/bin/which program.  Do you suggest we should
 remove it?  I don't have any problems with that...

The original `which' was a C shell script.  Its purpose was
specifically to explain how the C shell would locate a particular
command.  That's why the Korn shell introduced `type'.  This
functionality *needs* to be a shell builtin -- the only reason an
external C shell script worked (most of the time) was that csh insists
on reading .cshrc even for non-interactive shells.

-GAWollman

--
Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
[EMAIL PROTECTED]  | O Siem / The fires of freedom 
Opinions not those of| Dance in the burning flame
MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: C shell scripts (was: Re: which(1), rewritten in C?)

2000-03-03 Thread Peter Edwards

Assar Westerlund wrote:

 There's a real reason for not writing this in csh.  Because the
 built-in function will return results for csh, which might not be the
 right ones for other shells.
 
I got bitten by this by HP-UX 10's csh-based "which". My solaris-hosted
NFS home directory had the default Solaris .cshrc that changes $path.
Needless to say, "which" was somewhat misleading :-)
Ugh.
--
Peter.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message