[net.bugs.4bsd] Useful csh alias and free csh bug

andrew@garfield.UUCP (Andrew Draskoy) (03/22/85)

Here is a useful csh alias which I use to edit my last command.
I'm posting it here since others have told me that they have also
found it useful.

alias ec source ~/bin/ec
where ~/bin/ec contains:

echo !-1:q > /tmp/ec$$
$EDITOR /tmp/ec$$
cat /tmp/ec$$
eval `cat /tmp/ec$$`
rm /tmp/ec$$

The bug is so minor that I'm not even going to try and fix it,
however I thought I'd mention it in case someone is making a list
(a very big list) of csh bugs.

If you use ec to change your command to "history", you get (for example):

history
   189  set history=4
   190  ls
   191  ec
 -1000  ls%

The % at the end is your next prompt.  I have not been able to duplicate
this behavior in any other manner.
-- 
Andrew Draskoy
UUCP:	{akgua,allegra,cbosgd,ihnp4,mcvax,utcsri}!garfield!andrew
CDNNET:	andrew@garfield.mun.cdn
--
The opinions expressed above may not represent those of the author
after he has had some sleep.

andrew@garfield.UUCP (Andrew Draskoy) (03/24/85)

Guess what!  I made an error in my last posting (it always happens - no
doubt this one will have a problem as well.)  It seems that the !-1:q
should in fact be !-2:q.  That's what I get for making last-minute
improvements to things that used to work (and for using csh).
Also, I have discovered that if you stop your editor session, the csh
forgets about sourcing the rest of the file.  It looks like this may
work better by simply making the alias be:

alias ec 'all_the_commands_in_the_script'

which is what I had before, and it worked (using !-1:q).

If AT&T would release ksh I wouldn't have to worry about this (hint hint).
As it is, I will probably end up writing my own shell.

Andrew
-- 
Andrew Draskoy
UUCP:	{akgua,allegra,cbosgd,ihnp4,mcvax,utcsri}!garfield!andrew
CDNNET:	andrew@garfield.mun.cdn
--
The opinions expressed above may not represent those of the author
after he has had some sleep.

jerryp@tektools.UUCP (Jerry Peek) (03/25/85)

In article <2592@garfield.UUCP> andrew@garfield.UUCP (Andrew Draskoy) writes:
> Here is a useful csh alias which I use to edit my last command.
> I'm posting it here since others have told me that they have also
> found it useful.
> 
> alias ec source ~/bin/ec
> where ~/bin/ec contains:
> 
> echo !-1:q > /tmp/ec$$
> $EDITOR /tmp/ec$$
> cat /tmp/ec$$
> eval `cat /tmp/ec$$`
> rm /tmp/ec$$

The first line of "ec", !-1:q, referred to the ec command *itself*,
instead of the previous command... it should look like this instead:

	echo !-2:q > /tmp/ec$$

Otherwise, "ec" works great.

--Jerry Peek, UNIX Training Instructor, Tektronix, Inc.
US Mail:    MS 76-036, P.O. Box 500, Beaverton, OR 97077
uucp:       {allegra,decvax,hplabs,ihnp4,ucbvax}!tektronix!tektools!jerryp
CS,ARPAnet: jerryp%tektools@tektronix.csnet
Phone:      503/627-1603