[comp.sources.d] Bourne Again Shell?

mkhaw@teknowledge-vaxc.ARPA (Mike Khaw) (02/07/89)

Is it soup yet?  Who has it?

Thanks,
Mike Khaw
-- 
internet: mkhaw@teknowledge.com
uucp:	  {uunet|sun|ucbvax|decwrl|ames|hplabs}!mkhaw%teknowledge.com
hardcopy: Teknowledge Inc, 1850 Embarcadero Rd, POB 10119, Palo Alto, CA 94303

karl@triceratops.cis.ohio-state.edu (Karl Kleinpaste) (02/07/89)

mkhaw@teknowledge-vaxc.ARPA (Mike Khaw) writes:
   Is it soup yet?  Who has it?

Brian Fox and Paul Placeway.  Paul's fixing job control and adding his
tcsh editor.  ksh features will start arriving after stability is
achieved.

Patience, patience.

--Karl

seanf@sco.COM (Sean Fagan) (02/10/89)

In article <26563@teknowledge-vaxc.ARPA> mkhaw@teknowledge-vaxc.ARPA (Mike Khaw) writes:
>Is it soup yet?  Who has it?

More importantly, who named it?  And should they be shot?

-- 
Sean Eric Fagan  | "What the caterpillar calls the end of the world,
seanf@sco.UUCP   |  the master calls a butterfly."  -- Richard Bach
(408) 458-1422   | Any opinions expressed are my own, not my employers'.

mcdaniel@uicsrd.csrd.uiuc.edu (02/11/89)

Summary: what is this "Bourne-again (groan) shell"?

> Paul's fixing job control and adding his tcsh editor.  ksh features
> will start arriving after stability is achieved.

Why didn't they just implement ksh from the start?  I would think it
easier and cleaner to do that than to aim at sh and then patch in
changes.

Will the Bourne-again shell (bash? :-) be a superset of ksh?  If so,
what extra features are envisioned?

--

             Tim, the Bizarre and Oddly-Dressed Enchanter

Center for      |||  Internet, BITNET:  mcdaniel@uicsrd.csrd.uiuc.edu
Supercomputing  |||  UUCP:     {uunet,convex,pur-ee}!uiucuxc!uicsrd!mcdaniel
Research and    |||  ARPANET:  mcdaniel%uicsrd@uxc.cso.uiuc.edu
Development,    |||  CSNET:    mcdaniel%uicsrd@uiuc.csnet
U of Illinois   |||  DECnet:   GARCON::"mcdaniel@uicsrd.csrd.uiuc.edu"

peter@ficc.uu.net (Peter da Silva) (02/13/89)

What an opportunity to seal the breach.

Korn Shell with CSH history...

Is that too much to ask?
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Work: uunet.uu.net!ficc!peter, peter@ficc.uu.net, +1 713 274 5180.   `-_-'
Home: bigtex!texbell!sugar!peter, peter@sugar.uu.net.                 'U`
Opinions may not represent the policies of FICC or the Xenix Support group.

lmb@vicom.COM (Larry Blair) (02/13/89)

In article <3071@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes:
=What an opportunity to seal the breach.
=
=Korn Shell with CSH history...

I'm happy with ksh's history as-is.  What I miss is the {} syntax.
-- 
Larry Blair   ames!vsi1!lmb   lmb@vicom.com

les@chinet.chi.il.us (Leslie Mikesell) (02/13/89)

In article <3071@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes:

>Korn Shell with CSH history...
>Is that too much to ask?

I really hate to ask this, but...  What can you do with csh history that
you can't do with ksh's?  I really like the ksh ability to use editor
syntax to search for a previous command and modify it before re-execution.
Does csh have something like that? 

Les Mikesell

mike@thor.stolaf.edu (Mike Haertel) (02/14/89)

In article <42400008@uicsrd.csrd.uiuc.edu> mcdaniel@uicsrd.csrd.uiuc.edu writes:
>Why didn't they just implement ksh from the start?  I would think it
>easier and cleaner to do that than to aim at sh and then patch in
>changes.

Reading all the speculation about bash lately, I thought I'd throw in
a little fact.

1.  It is Bourne shell compatible.  Not all the Korn shell features have
been implemented, for example "select" which is bogus.  It certainly has
the provisions for functions, local variables, and aliases though.

2.  It supports both csh style history and command line editing.  The
latter supports at least vi and emacs modes and (at least in the latter)
user-configured keymaps.  (Actually, the GNU command line editing library
is used and all programs that use it refer to the same customization file.)

3.  I have no idea when it will be available.  I've been using it off
and on for some time now, and there are still bugs.
-- 
Mike Haertel					mike@wheaties.ai.mit.edu
			In Hell they run VMS.

oz@yunexus.UUCP (Ozan Yigit) (02/14/89)

In article <42400008@uicsrd.csrd.uiuc.edu> mcdaniel@uicsrd.csrd.uiuc.edu writes:
>
>Will the Bourne-again shell (bash? :-) be a superset of ksh?  If so,
>what extra features are envisioned?
Hehhee... It is impossible to be a superset of KSH. If a feature is
not there, just ask the author, and he will put it in... :-). Seen
the KSH book lately ?? ;-)

oz


-- 
... and I say to them, 	    		Usenet:    oz@nexus.yorku.ca
   `Where the hell were you        	......!uunet!utai!yunexus!oz
    when the page was blank?'		Bitnet: oz@[yulibra|yuyetti]
		Harlan Ellison  	Phonet: +1 416 736-5257x3976

shirono@hcx3.SSD.HARRIS.COM (02/14/89)

In comp.sources.d, les@chinet.chi.il.us writes:
> In article <3071@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes:
> >Korn Shell with CSH history...
> >Is that too much to ask?
>
> I really hate to ask this, but...  What can you do with csh history that
> you can't do with ksh's?  I really like the ksh ability to use editor
> syntax to search for a previous command and modify it before re-execution.
> Does csh have something like that? 

Ksh and csh have two different philosophies as far as command history
editing goes.  They both have good and bad points.

What I miss from the csh is the ability to say:
	``I want words 0 thru 5 and 7 thru 11.''
		!:0-5 !:7-11
or
	``I want everything exactly the same, but change the string `foo'
	  for `bar' in the last word.''
		!:0- !$:gs/foo/bar/

These changes might look trivial, but when your command line has wrapped
around (or scrolled left) a few times it gets to be a drag.  Even worse is

	``I want to apply command `foo' to the last word of the previous
	  command.''

		foo !$

Note, I'm not saying these can't be done with ksh, but I'm saying that I'd
rather write !$, however cryptic, than go through an unending sequence of
keystrokes to accomplish the exact same thing.

Perhaps having both would be the best.

--Roberto
______________________________________________________________________________
                               ||   Internet: shirono@ssd.harris.com
     Roberto Shironoshita      ||
      Harris Corporation       ||             ...!novavax---\
   Computer Systems Division   ||   UUCP:     ...!uunet-------!hcx1!shirono
                               ||             ...!mit-eddie-/
------------------------------------------------------------------------------
DISCLAIMER: The opinions expressed here are my own; they in no way reflect the
            opinion or policies of Harris Corporation.

peter@ficc.uu.net (Peter da Silva) (02/15/89)

In article <7700@chinet.chi.il.us>, les@chinet.chi.il.us (Leslie Mikesell) writes:
> In article <3071@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes:
> >Korn Shell with CSH history...
> >Is that too much to ask?

> I really hate to ask this, but...  What can you do with csh history that
> you can't do with ksh's?

We've been over this quite a few times, but what it basically amounts to
is that CSH history is more convenient for simple command line manipulations.

	% ls *.a *.b *.c
	...
	% rm !^
	rm *.a

Is handier than:

	vi$ ls *.a *.b *.c
	...
	vi$ <ESC>kcwrm<ESC>E D<CR>

Or:

	emacs$ ls *.a *.b *.c
	...
	emacs$ <^P><DEL><DEL>rm<ESC>w<ESC>w<BS><^K><CR>

(you will note I'm not an Emacs user, but that's about the amount of typing
 involved)

In every other respect ksh is superior to csh, and there are lots of cases
where ksh history is superior to csh, but for day-to-day stuff I find ksh
history very trying...
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Work: uunet.uu.net!ficc!peter, peter@ficc.uu.net, +1 713 274 5180.   `-_-'
Home: bigtex!texbell!sugar!peter, peter@sugar.uu.net.                 'U`
Opinions may not represent the policies of FICC or the Xenix Support group.

karl@ficc.uu.net (karl lehenbauer) (02/15/89)

In article <3089@ficc.uu.net>, peter@ficc.uu.net (Peter da Silva) writes:
> We've been over this quite a few times, but what it basically amounts to
> is that CSH history is more convenient for simple command line manipulations.
 
But doesn't this mean we'll have to start backslashing all our '!' characters
in mailpaths and such again?  Ick.
-- 
-- uunet!ficc!karl	"An expression of deep worry and concern failed to
-- karl@ficc.uu.net	 cross either of Zaphod's faces."  -- Hitchiker's Guide

peter@ficc.uu.net (Peter da Silva) (02/16/89)

In article <3099@ficc.uu.net>, karl@ficc.uu.net (karl lehenbauer) writes:
> In article <3089@ficc.uu.net>, peter@ficc.uu.net (Peter da Silva) writes:
> > We've been over this quite a few times, but what it basically amounts to
> > is that CSH history is more convenient for simple command line manipulations.

> But doesn't this mean we'll have to start backslashing all our '!' characters
> in mailpaths and such again?  Ick.

Well, the assumption is that they'd use the latest csh as the model, and have
a histchars-type option to select what the history characters are...

And, of course, you would be able to turn it off.

While we're dreaming, you know...
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Work: uunet.uu.net!ficc!peter, peter@ficc.uu.net, +1 713 274 5180.   `-_-'
Home: bigtex!texbell!sugar!peter, peter@sugar.uu.net.                 'U`
Opinions may not represent the policies of FICC or the Xenix Support group.

lmb@vicom.COM (Larry Blair) (02/16/89)

In article <46100006@hcx3> shirono@hcx3.SSD.HARRIS.COM writes:
=	``I want to apply command `foo' to the last word of the previous
=	  command.''
=
=		foo !$

foo $_

=	``I want everything exactly the same, but change the string `foo'
=	  for `bar' in the last word.''
=		!:0- !$:gs/foo/bar/

This is one on the incredibly cryptic things about csh that I enjoy with
ksh.  Type `$' and move back to the word to change.  It may be a couple
more keystrokes, but it's actually faster because I don't have to think
about it.  Btw, the most common use of "gs", "!cmd:gs/old/new/" is actually
easier ksh: "r old=new cmd".

I'm not saying that there aren't things lacking in ksh; I miss "!! newstuff"
and "!*" would be really useful.  It's just nice to only have to deal with
one editor syntax.  I don't know of a single person who has used ksh and
gone back to csh.  I hope that the GNU shell is a superset of ksh and not
some ksh/csh compromise.
-- 
Larry Blair   ames!vsi1!lmb   lmb@vicom.com

jim@tiamat.fsc.com (Jim O'Connor) (02/16/89)

In article <3089@ficc.uu.net>, peter@ficc.uu.net (Peter da Silva) writes:
> 
> We've been over this quite a few times, but what it basically amounts to
> is that CSH history is more convenient for simple command line manipulations.
> 
> 	% ls *.a *.b *.c
> 	...
> 	% rm !^
> 	rm *.a
> 
> Is handier than:
> 
> 	vi$ ls *.a *.b *.c
> 	...
> 	vi$ <ESC>kcwrm<ESC>E D<CR>

Doesn't something along the lines of:

vi$ r ls=rm

work, and without as much typing.  Also, If you put the command number in your
prompt, it's also easy to do.

1$ ls *.a *.b *.c
...
2$ more *.a
3$ pr *.b | lp
4$ cat *.c | mail someone-I-dont-like
[ the exact command are irrellevant, the point is that there are some there]
5$ r 1 ls=rm

Granted, this may not be easier than what the csh has to offer, but is does
appear easier than the ksh example offered.

> In every other respect ksh is superior to csh, and there are lots of cases
> where ksh history is superior to csh, but for day-to-day stuff I find ksh
> history very trying...

The only thing I don't really like is that when you repeat an entire command
using "r" (really some alias invloving fc), it goes in the history again.  This
is probably the most correct thing to do, but there are times when I don't
want my recent history to get filled with the same command over and over.

------------- 
James B. O'Connor			jim@tiamat.fsc.com
Filtration Sciences Corporation		615/821-4022 x. 651

*** Altos users unite! mail to "info-altos-request@tiamat.fsc.com" ***

gm@romeo.cs.duke.edu (Greg McGary) (02/16/89)

In article <1491@vicom.COM> lmb@vicom.COM (Larry Blair) writes:
>In article <46100006@hcx3> shirono@hcx3.SSD.HARRIS.COM writes:
>=	``I want to apply command `foo' to the last word of the previous
>=	  command.''
>=
>=		foo !$
>
>foo $_

These aren't the same.
The ksh `$_' is the final argument *after* globbing,
while the csh `$!' is the final argument *before* globbing.  e.g.,

a directory contains the following:

foo	bar	foobar

In csh:
	% echo *
	foo bar foobar
	% echo !$
	echo *
	foo bar foobar

In ksh:
	$ echo *
	foo bar foobar
	$ echo $_
	foobar

-- Greg McGary
-- 4201 University Drive #102, Durham, NC 27707       voice: (919) 490-6037
-- {decvax,hplabs,seismo,mcnc}!duke!gm                 data: (919) 493-5953
--                                  gm@cs.duke.edu

keithe@tekgvs.LABS.TEK.COM (Keith Ericson) (02/17/89)

In article <3071@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes:
>What an opportunity to seal the breach.
>
>Korn Shell with CSH history...
>
>Is that too much to ask?

No, as long as it's an ADDITION TO and not a REPLACEMENT FOR the current
Korn Shell history mechanism.

Thank you for your consideration.

kEITH

schaefer@ogccse.ogc.edu (Barton E. Schaefer) (02/17/89)

In article <3103@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes:
} In article <3099@ficc.uu.net>, karl@ficc.uu.net (karl lehenbauer) writes:
} > In article <3089@ficc.uu.net>, peter@ficc.uu.net (Peter da Silva) writes:
} > > We've been over this quite a few times, but what it basically amounts to
} > > is that CSH history is more convenient for simple [...] manipulations.
} > But doesn't this mean we'll have to start backslashing all our '!'
} > characters in mailpaths and such again?  Ick.
} Well, the assumption is that they'd use the latest csh as the model, and have
} a histchars-type option to select what the history characters are...

The solution to the "backslashing all our '!'" problem is to add a new
variable, analogous to "nonomatch".  Just as "nonomatch" causes the
globbing pattern to be returned when no matching files are found, the
new variable would cause the history pattern to remain unchanged if no
history substitution is found.  The variable could be called "nonohist"
or some similar psuedo-explanatory abbreviation.

Come to think of it, "nonovar" would come in handy, too. :-)

Incidentally (plug plug) the next version of Dan Heller's MUSH (Mail
User's SHell), the mailer with everything, has a variable "nonobang"
to control its csh-style history mechanism in precisely that way.
Coming moderatedly ;-) soon to a comp.sources.unix near you.
-- 
Bart Schaefer       "Dogs are the animal byproducts in the wienie of life."
                                                                -- Garfield
CSNET / Internet                schaefer@cse.ogc.edu
UUCP                            ...{sun,tektronix,verdix}!ogccse!schaefer

jewett@hpl-opus.HP.COM (Bob Jewett) (02/17/89)

> We've been over this quite a few times, but what it basically amounts to
> is that CSH history is more convenient for simple command line manipulations.

I find the opposite.  Especially important for new users is the fact that
command-line manipulation is the same (generally) as their editor.

> In every other respect ksh is superior to csh, and there are lots of cases
> where ksh history is superior to csh, but for day-to-day stuff I find ksh
> history very trying...

I find ksh's history much better overall than csh's, especially in the
day-to-day stuff.  The ability to call up an actual "vi" on a multi-line
command is very nice.  It makes script prototyping much faster.

The csh feature I miss is {} filename expansion.

Bob Jewett

m1tag00@fed.frb.gov (Tim A. Grunwald) (02/17/89)

In article <3099@ficc.uu.net>, karl@ficc (karl lehenbauer) writes:
> 
>But doesn't this mean we'll have to start backslashing all our '!' characters
>in mailpaths and such again?  Ick.
>-- 
>-- uunet!ficc!karl	"An expression of deep worry and concern failed to
>-- karl@ficc.uu.net	 cross either of Zaphod's faces."  -- Hitchiker's Guide

	You obviously don't use Gnu Emacs to read and send mail.

	Tim Grunwald
	Federal Reserve Board, Washington, DC, 20551
	uucp: uunet!fed!m1tag00   internet: m1tag00@fed.frb.gov

root@tscs.UUCP (Admin) (02/17/89)

In article <7700@chinet.chi.il.us> les@chinet.chi.il.us (Leslie Mikesell) writes:
>In article <3071@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes:
>
>>Korn Shell with CSH history...
>>Is that too much to ask?
>
>I really hate to ask this, but...  What can you do with csh history that
>you can't do with ksh's?  I really like the ksh ability to use editor
>syntax to search for a previous command and modify it before re-execution.
>Does csh have something like that? 

I'll have to admit to not having much experience with the Korn shell (a couple
of hours at 1200 baud), but I have not figured out how to emulate some of my
favorite csh command editing features:

(assume the following command sequence)

(1): tar cvf /tmp/foobar ./{src,bin} ./local/bar
(2): chmod 440 !:2	(expands to: chmod 440 /tmp/foobar)
(3): chown root !$	(expands to: chown root /tmp/foobar)
(4): ls -l !ta:3-$	(expands to: ls -l ./{src,bin} ./local/bar)
			(which works out to: ls -l ./src ./bin ./local/bar)

These features of csh are handy, if the Korn shell can do this, I'd be
interested in hearing about it.  My only real gripe about csh is the
inability to edit across multiple arguments such as:

(5): find . -type f -print | xargs -t chmod 644
	It would be nice to be able to change " f " to " d " and
	"644" to "755" a little bit easier than:
(6): !!:0-2 d !!:4-$:s/644/755/
	It's too bad you just can't use: !!:s/ f / d /:s/644/755/
	Granted if you had an editor to edit your command line, this last
	example would not be a problem; however, being able to easily
	extract various arguments from any of your previous commands
	with only a few keystrokes is great!!

I am not attempting to start a religious debate, I'm only curious if the
Korn shell can do argument substitution as well as the C shell?

john@frog.UUCP (John Woods) (02/17/89)

In article <3089@ficc.uu.net>, peter@ficc.uu.net (Peter da Silva) writes:
K>In article <7700@chinet.chi.il.us>, les@chinet.chi.il.us (Leslie Mikesell) writes:
n>> I really hate to ask this, but...  What can you do with csh history that
o>> you can't do with ksh's?
w>We've been over this quite a few times, but what it basically amounts to
 >is that CSH history is more convenient for simple command line manipulations
Y> 	% ls *.a *.b *.c
o> 	...
u> 	% rm !^
r> 	rm *.a
 > Is handier than:
T> 	emacs$ ls *.a *.b *.c
o> 	...
o> 	emacs$ <^P><DEL><DEL>rm<ESC>w<ESC>w<BS><^K><CR>
ls> 
Try
 	emacs$ rm <ESC>2<ESC>.

Granted, it is more keystrokes that !^, but it generalizes very nicely.
-- 
John Woods, Charles River Data Systems, Framingham MA, (508) 626-1101
...!decvax!frog!john, john@frog.UUCP, ...!mit-eddie!jfw, jfw@eddie.mit.edu

Presumably this means that it is vital to get the wrong answers quickly.
		Kernighan and Plauger, The Elements of Programming Style

alanf%smile@Sun.COM (Alan Fargusson @ peace with the world) (02/18/89)

Most people seem unaware of the <esc><n>_ construct in the Korn shell.
This construct gives you the nth parameter from the previous command.
For some reson the parameters are numbered from one, so <esc>1_ give
you the command name.  I do miss the {} construct.

In article <278@tscs.UUCP>, root@tscs.UUCP (Admin) writes:
> 
> (1): tar cvf /tmp/foobar ./{src,bin} ./local/bar

tar cvf /tmp/foobar ./src ./bin ./local/bar

> (2): chmod 440 !:2	(expands to: chmod 440 /tmp/foobar)

chmod 440 <esc>3_

> (3): chown root !$	(expands to: chown root /tmp/foobar)

chown root $_
  or
chown root <esc>_

> (4): ls -l !ta:3-$	(expands to: ls -l ./{src,bin} ./local/bar)
> 			(which works out to: ls -l ./src ./bin ./local/bar)

I would do this by editing the command line and removing everything up to the
parameters I wanted, then inserting the ls -l.  It isn't that bad.

Whenever I try and do something like number 4 in csh I usually blow it and
end up typing the whole thing in anyway.  The <esc><n>_ construct expands
when you type it so if you get it wrong you can backspace and try again.
- - - - - - - - - - - - - - - - - - - - -
Alan Fargusson		Sun Microsystems
alanf@sun.com		..!sun!alanf

michael@stb.UUCP (Michael) (02/18/89)

What can you do with CSH history that you can't do with ksh?
Well, first, there's my favorite:
root -fc '%%'    (my histchars defines % instead of !)

Second, you can grab parts from several commands as in
head !-2:* !-4:*

Third, and most important to me, is that I can decide to use the
history features AFTER I've started to type the commands.

			Michael
(root is a setuid root program of mine that sends its args to the shell.
Since I'm sysadmin on my system, this is useful to me)
: --- 
: Michael Gersten			 uunet.uu.net!stb!michael
:					crash!gryphon!denwa!stb!michael
: Coff Coff <=== Stop smoking.

dave@galaxia.Newport.RI.US (David H. Brierley) (02/18/89)

In article <1491@vicom.COM> lmb@vicom.COM (Larry Blair) writes:
>
>I'm not saying that there aren't things lacking in ksh; I miss "!! newstuff"
>and "!*" would be really useful.  It's just nice to only have to deal with
>one editor syntax.

For the "!! newstuff" try using "<ESC>kA newstuff".  I dont see where the
problem is with the "!*" syntax, just pull back the last command and edit
the first word.  I think the most useful thing for someone who wants to
make the most of the history mechanism in the ksh is if they have a very
thorough understanding of vi.  I suppose a thorough understanding of emacs
would allow you to make efficient use of emacs mode as well.

I would like to see a csh user show me how to achieve the following using
the csh history mechanism: retrieve the third previous command that contains
the string "foo" and then change the fourth word on the line to the word
"bar".  In ksh: "<ESC>/foo<CR>nn3Wcwbar<CR>".  Like I said, a knowledge of
vi is extremely helpful.
-- 
David H. Brierley
Home: dave@galaxia.Newport.RI.US   {rayssd,xanth,lazlo,jclyde}!galaxia!dave
Work: dhb@rayssd.ray.com           {sun,decuac,gatech,necntc,ukma}!rayssd!dhb

roy@sts.sts.com (02/23/89)

Where does one get this "Bourne-again" shell?  Is it public domain?


Roy Bixler                   | UUCP: ...!{claris,sun}!sts!roy
Semiconductor Test Solutions | phones: (408) 727-2885 x132 (work)
4101 Burton Dr.              |         (408) 289-1035      (home)
Santa Clara, CA  95054

davids@iscuva.ISCS.COM (David Schmidt) (02/24/89)

How can one get a copy of bash?  I haven't seen it on UUNET yet (unless it
doesn't go by the name bash).  We don't have ksh and the sh that we have
has some bugs in it.  I'd just as soon try bash!

Please E-mail responces and if others want the information I'll post
a summary to the net.
-- 
David Schmidt              UUCP:  davids@iscuva.ISCS.COM
ISC Systems Corporation           (uunet!iscuva!davids)
East 22425 Appleway        Phone: +1 509 927-5479
Liberty Lake, WA  99019

michael@stb.UUCP (Michael) (03/11/89)

In article <544@galaxia.Newport.RI.US> dave@galaxia.Newport.RI.US (David H. Brierley) writes:
>I would like to see a csh user show me how to achieve the following using
>the csh history mechanism: retrieve the third previous command that contains
>the string "foo" and then change the fourth word on the line to the word
>"bar".  In ksh: "<ESC>/foo<CR>nn3Wcwbar<CR>".  Like I said, a knowledge of
>vi is extremely helpful.
>-- 
>David H. Brierley
>Home: dave@galaxia.Newport.RI.US   {rayssd,xanth,lazlo,jclyde}!galaxia!dave
>Work: dhb@rayssd.ray.com           {sun,decuac,gatech,necntc,ukma}!rayssd!dhb


Ok. history | fgrep foo | tail -3 | head -1
!xyz:0-3 bar !xyz:5-$

Done. Readable.

Now, my turn: How do you combine multiple commands in the KSH history
mode? My copy of ksh does not implement vi's yank feature, so I cannot
combine parts from command 32 with command 35.

Also, ksh's vi mode has the /'s and ?'s backwards, as well as G (which
goes to the first command, not the last command).

(I know what you'll say, think of editing a file where the new lines go at
the top. But then why can't I say 1G, and why are the numbers on the lines
backwards?)

			Michael
: --- 
: Michael Gersten			 uunet.uu.net!stb!michael
:					crash!gryphon!denwa!stb!michael
: Its not the Coff that carries you off, its the coffin they carry you off in.

gregg@ihlpb.ATT.COM (Wonderly) (03/13/89)

From article <10659@stb.UUCP>, by michael@stb.UUCP (Michael):
> ...
>
> Now, my turn: How do you combine multiple commands in the KSH history
> mode? My copy of ksh does not implement vi's yank feature, so I cannot
> combine parts from command 32 with command 35.
> 

since ksh's history file is essentially read only, you can use 'dw' or
whatever to delete the words that you want from one line and insert them
into another with 'p' or 'P' (or the equivalent, if it works, in emacs mode)...

> Also, ksh's vi mode has the /'s and ?'s backwards, as well as G (which
> goes to the first command, not the last command).
> 
> (I know what you'll say, think of editing a file where the new lines go at
> the top. But then why can't I say 1G, and why are the numbers on the lines
> backwards?)

The answer is that the normal thing is to search backwards through history,
so that is the easiest (no shift key).  Certainly complexity of operation
is an issue when designing the interface for a tool.  Here, David did the
correct thing!

-- 
Gregg Wonderly                             DOMAIN: gregg@ihlpb.att.com
AT&T Bell Laboratories                     UUCP:   att!ihlpb!gregg

asmodeus@tree.UUCP (Jonathan Ballard) (03/14/89)

> Ok. history | fgrep foo | tail -3 | head -1
> !xyz:0-3 bar !xyz:5-$
> 
> Done. Readable.

I have no "xyz" command so this trick is useless for me.  
Just wanted to say that piping isn't only for csh.  Try doing it without
piping in csh.  This can't be executed unless you did it with 
sh -c `...`    
type format.

> 
> Now, my turn: How do you combine multiple commands in the KSH history
> mode? My copy of ksh does not implement vi's yank feature, so I cannot
> combine parts from command 32 with command 35.
> 
Well... mine does and a "<ESC>32GY35G$p" will combine them.
Maybe you used "yy" instead of "Y" as a yank command. 
Another way would be to type "fc -e" and edit the history with the editor
you chose. (real editor - not editor look alike)  Then when done 
just execute that line.

> Also, ksh's vi mode has the /'s and ?'s backwards, as well as G (which
> goes to the first command, not the last command).
> 
> (I know what you'll say, think of editing a file where the new lines go at
> the top. But then why can't I say 1G, and why are the numbers on the lines
> backwards?)

/ searchs downwards in a file - search backwards in history
? searchs upwards in a file - searches forwards in history
G alone will goto the least numbered history line.  But with a number before
	it then it will try to go to that the history line number. 

The numbers are on the l are backwards? Since when?

-- 
----Asmodeus - Jonathan Ballard  ..!csusac!tree!asmodeus
				 ..!pacbell!sactoh0!tree!asmodeus
"I'm going to create the best game ever heard of!
	Might take a few years thou..." -me

ebh@argon.UUCP (Ed Horch) (03/18/89)

In article <10659@stb.UUCP> michael@stb.UUCP (Michael) writes:
>Now, my turn: How do you combine multiple commands in the KSH history
>mode? 

I don't know about vi mode, but in emacs mode it works exactly as 
you expect.  Suppose you have "foo" and "bar" in your history file,
and you want to make "foo | bar".  Here's how you do it (pretend
that _ is the cursor):

     TYPE                SEE              COMMENT
  ^Rfoo<cr>            $ foo_             finds foo
  ^A                   $ _foo             cursor is on top of 'f'
  ^K                   $ _                put "foo" in kill buffer
  ^Rbar<cr>            $ bar_             finds bar
  ^A                   $ _bar             cursor is on top of 'b'
  ^Y                   $ foo_bar          yank "foo" from kill buffer
  <sp>|<sp>            $ foo | _bar       insert the rest; you're done

-Ed

Will the world *ever* decide what ^T should do?

michael@stb.UUCP (Michael) (03/21/89)

In article <237@tree.UUCP> asmodeus@tree.UUCP (Jonathan Ballard) writes:
>> Ok. history | fgrep foo | tail -3 | head -1
>> !xyz:0-3 bar !xyz:5-$
>> 
>> Done. Readable.
>
>I have no "xyz" command so this trick is useless for me.  
>Just wanted to say that piping isn't only for csh.  Try doing it without
>piping in csh.  This can't be executed unless you did it with 
>sh -c `...`    

Alright. Lets try this again.
(30) % history | fgrep foo | tail -3 | head -1
 27  foo -i *.a -o *.c -n -xyzzy -l local
(31) % !27:0-3 *.b !27:5-$
foo -i *.a -o *.b -n -xyzzy -l local
<output of foo follows>

By !xyz in my original posting, I did not mean "command named xyz", I ment
the number of the command returned by the original history command.

>> Now, my turn: How do you combine multiple commands in the KSH history
>> mode? My copy of ksh does not implement vi's yank feature, so I cannot
>> combine parts from command 32 with command 35.
>> 
>Well... mine does and a "<ESC>32GY35G$p" will combine them.
>Maybe you used "yy" instead of "Y" as a yank command. 

Well of course I used yy. Thats how I yank in vi. :-)
Just checked. My version of ksh doesn't even support "Y" for yanks.

>Another way would be to type "fc -e" and edit the history with the editor
>you chose. (real editor - not editor look alike)  Then when done 
>just execute that line.
>
>> Also, ksh's vi mode has the /'s and ?'s backwards, as well as G (which
>> goes to the first command, not the last command).
>> 
>> (I know what you'll say, think of editing a file where the new lines go at
>> the top. But then why can't I say 1G, and why are the numbers on the lines
>> backwards?)
>
>/ searchs downwards in a file - search backwards in history
>? searchs upwards in a file - searches forwards in history
>G alone will goto the least numbered history line.  But with a number before
>	it then it will try to go to that the history line number. 
>
>The numbers are on the l are backwards? Since when?

If / goes to higher numbered lines corresponding to earlier commands, then
1G should go to the lowest numbered line (most recent command). It doesm't.

This is what I mean by numbers on the lines are backwards. And yes, it does
make a difference to me (I hit ? and find nothing like what I expected.
I then do "G" to get to the end, but are instead at the beginning. Etc.)

>----Asmodeus - Jonathan Ballard  ..!csusac!tree!asmodeus

			Michael
: --- 
: Michael Gersten			 uunet.uu.net!stb!michael
:	michael@stb.uu.net <mx mailers>	crash!gryphon!denwa!stb!michael
: "Robitussin" for computers? This has gone too far. Where's "Penicillian"?
: (rob. is Coff-medicine to let COFF people run bsd-dependent GNU stuff).