[comp.unix.shell] T, csh bugs

subbarao@phoenix.Princeton.EDU (Kartik Subbarao) (10/24/90)

This was going to be a reply to an earlier article saying that you couldn't have multiline
aliases. My response was going to be sure you can, if you \ a ^J. For example, what I was
trying to do was:

tcsh % alias foo 'foreach i (*) \^J echo $i \^J end'

The command works fine if not "aliased" -- that is, if I just type

tcsh % foreach i (*) \^J echo $i \^J end 

on one line, tcsh will nicely do the foreach loop for me. If, however, I put it into an alias,
tcsh decides to log me out.

If I do this aliasing in csh, csh simply will segmentation fault. Why is this the case?

Also, this bug reminded me of some earlier bugs which I had discovered with csh and tcsh.

Bug 1:

Have you ever tried typing:

tcsh % ``

Notice it will tell you "Segmentation Fault" in tcsh - but this is not the segmentation fault of
tcsh -- it's that of the child process that tcsh forks due to this.


Bug 2:

I also wanted to alias "which" as follows:

% alias which "/bin/file `/usr/ucb/which \!*`"

But did csh or tcsh let me? Of course not. csh decided to Abort and dump 8 megs of core, and
tcsh simply decided to fork tons of processes to fill up my process table when the command
as not &'ed. If I did '&' it, it would simply hang.


And that's where it stands. But I'll tell you something though. I'll never convert to sh** or
something like that.

Oh and by the way, bug fixes are appreciated anyone !


				-Kartik









(I need a new .signature -- any suggestions?)
subbarao@{phoenix or gauguin}.Princeton.EDU -|Internet
kartik@silvertone.Princeton.EDU (NeXT mail)       -|	
SUBBARAO@PUCC.BITNET			          - Bitnet

mday@iconsys.icon.com (Matt Day) (10/29/90)

In article <3538@idunno.Princeton.EDU> subbarao@phoenix.Princeton.EDU (Kartik Subbarao) writes:
>Have you ever tried typing:
>
>tcsh % ``
>
>Notice it will tell you "Segmentation Fault" in tcsh - but this is not the
>segmentation fault of tcsh -- it's that of the child process that tcsh forks
>due to this.

This bug (and many other classic csh bugs) are fixed in version 5.19, which
you can download via anonymous ftp from tesla.ee.cornell.edu:/pub/tcsh-5.19/...

>Bug 2:
>
>I also wanted to alias "which" as follows:
>
>% alias which "/bin/file `/usr/ucb/which \!*`"
>
>But did csh or tcsh let me? Of course not. csh decided to Abort and dump 8
>megs of core, and tcsh simply decided to fork tons of processes to fill up
>my process table when the command as not &'ed. If I did '&' it, it would
>simply hang.

That's because it's having trouble trying to accomplish what you asked it to
do, alias a command containing the execution of a command being passed the
current argument list, which just happens to contain the very same execution
of a command being passed the current argument list, etc ad nauseum, because
you told it to evaluate the command between the backquotes before defining
the alias, rather than "postponing" evaluation until you actually wanted to
use the alias, which I assume you wanted to do.  The poor [t]csh tries to
figure out your cute little recursive definition until it runs out of memory
or processes.  If you enclose the contents of the alias with single-quotes
rather than double-quotes, to "protect" the contents of the alias, it works
just fine.

As for multi-line alias support, it doesn't exist in the tcsh yet, but I'm
sure it wouldn't be impossible to add..
-- 
- Matthew T. Day, Sanyo/Icon, mday@iconsys.icon.com || uunet!iconsys!mday