Line at a time scripts in csh

00771g-Lukas lukas at ihlpf.ATT.COM
Fri Jan 27 01:03:55 AEST 1989


In article <891 at auspex.UUCP> guy at auspex.UUCP (Guy Harris) writes:
>>I just wrote the script as given, and tried it with sh, ksh, and csh, and it
>>worked for all three.
>
>The "csh" on your system must be something other than the C shell, then,
>because the C shell is quite different from the Bourne shell, and it
>complained as soon as it saw
>
>	ifs_def=$IFS

No, it turns out that my "csh" is in fact the C shell, but I must have
been doing something wrong. Im hoping that you can enlighten me. I made
the script executable, then issued it from csh, vis:

	lpf lukas> csh
	% foo
	# correct! results of foo here
	% exit
	lpf lukas>

However, when I issued:

	lpf lukas> csh foo

It failed with messages like you suggested. So, I threw in a
"ps" into "foo", and found that "csh" forked a "sh" process to actually
run "foo", and that is why it worked. I guess I didnt expect that.
Why was a "sh" child produced, instead of another "csh" (or, anyway,
a "ksh", which is my login shell, and the value of SHELL)? Any ideas?
Parenthetically, I did the same sort of thing with "ksh" instead of "csh",
and another "ksh" (NOT a "sh") was forked to run the "ps".

As a side issue, is there any way to know, from within a process, what
the "current" shell is? It would seem to me that an environment variable
would be best. Something like "CURR_SHELL", that would have "sh", "ksh",
etc., or somesuch. I suggested some such to David Korn for the ksh, but
he did not see the need. I suppose that I could use the output of "ps",
then track back child to parent until I got to a shell, but that seems
like an awful lot of work. Any ideas on this?
-- 

	John Lukas
	att!ihlpf!lukas
	312-510-6290



More information about the Comp.unix.questions mailing list