Subject: Re: add less in /rescue
To: mouss <>
From: Greg A. Woods <>
List: tech-userlevel
Date: 07/08/2004 01:02:46
[ On Thursday, July 8, 2004 at 02:04:57 (+0200), mouss wrote: ]
> Subject: Re: add less in /rescue
> Greg A. Woods wrote:
> > "Ed" is in fact a very fine and _very_ useful utility, as ascetic as it
> > may be.  I think learning to use "ed" well can still teach most people
> > more about Unix than any other single utility could ever do.  Except
> > maybe sh.  :-)
> I think you're exagerating a bit.

No, I'm _very_ serious about all of that.

> ed isn't only an obscure program,

Well to some folks it might be obscure, but that's my point.  If more
people learned at least the basics of 'ed' with enough depth that they
could use its basic features without having to read the manual again,
then they would not only be able to use it as a text editor in an
emergency but they'd also have learned a great deal about Unix in
general too.

> it's 
> also an obsolete piece of code

Well, the original v7 implementation of ed is certainly obsolete and
unmaintained code, but the implementation that's included in NetBSD is
not in the least -- it is after all an 8-bit-clean, POSIX-compliant line

> Also I don't see anything you can learn by using ed, except learning the 
> patience and resistance not to destroy the keyboard (the monitor is more 
> expensive so resistance is easy) The last time I used ed, I f+-=ed down 
> my disklabel multiple times before getting it right [of course, french 
> keyboard (or should I say "freedom keyboard"?) on a US kernel wasn't 
> helping, but heh...].

Well that just proves you do have lots to learn from 'ed' yet!  ;-)

> > Howerver there is still 'sh'!  :-)
> > 
> > 	i=1
> > 	dmesg | while read line ; do
> > 		echo $line
> > 		if [ $((i++ % 24) -eq 0 ]; then

oops -- I missed a closing parenthesis there!  ;-)

> > 			read ret < /dev/tty
> > 		fi
> > 	done
> > 
> > It doesn't handle counting of wrapped lines of course, but it's better
> > than trying to use <CTRL-S>!  :-)
> ahem. Is the game an "obfuscated more context" or what?

Well, the idea is that you'd put that script or one like in the form of
a shell function in the .profile you keep in /rescue with other similar
goodies you might like to have so that when the day comes that you're
under pressure to fix something and you need a quick-and-dirty "pager"
in the /rescue environment then all you have to do is use it.

I do regularly type "commands" at the prompt as complex as the above
loop, but under the pressures one might face when using /resuce it is
definitely an error prone process, and when using the shell on
installation media -- i.e. without a command-line editor -- it can be
extremely tedious to do, so usually I try to remember to add such helper
scripts to a goodies file that'll end up where I need it the next time
I'm in the same situation.  I don't like having to do tedious things
such as that more than once.  Unfortunately when I end up using someone
else's installation media instead of my own home-grown variant I'm
without all my little helper functions and the need to be able to deal
with such situations is one of the lessons that learning 'ed' can help
teach us all....

(meanwhile I think I'll write a note to remind myself to include the full
featured command-line editor in the shell on the next CD-ROM I build :-)

						Greg A. Woods

+1 416 218-0098                  VE3TCP            RoboHack <>
Planix, Inc. <>          Secrets of the Weird <>