Path: utzoo!attcan!uunet!lll-winken!ames!xanth!ukma!tut.cis.ohio-state.edu!osu-cis!att!ihlpf!lukas From: lukas@ihlpf.ATT.COM (00771g-Lukas) Newsgroups: comp.unix.questions Subject: Re: Line at a time scripts in csh Message-ID: <7449@ihlpf.ATT.COM> Date: 26 Jan 89 15:03:55 GMT References: <4116@paris.ics.uci.edu> <909@ubu.warwick.UUCP> <7296@ihlpf.ATT.COM> <872@auspex.UUCP> <7372@ihlpf.ATT.COM> <891@auspex.UUCP> Reply-To: lukas@ihlpf.UUCP (00771g-Lukas,J.) Organization: AT&T Network Systems - Lisle Illinois Lines: 44 In article <891@auspex.UUCP> guy@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