Subject: Re: add less in /rescue
To: None <tech-userlevel@netbsd.org>
From: Ian Zagorskih <ianzag@megasignal.com>
List: tech-userlevel
Date: 07/03/2004 15:46:07
On Saturday 03 July 2004 00:01, David Laight wrote:

> > Occasionally today i had to actually use tools from /rescue and i found
> > quite annoying feature: with mounted root / i don't see less, more, head,
> > tail, grep, vi - nothing. So i cannot actually inspect for example output
> > of dmesg.
> >
> > Any ideas ? Looks like /rescut need some tools to manage text output.
>
> dmesg 3<&0 | while read -r line; do \
> 	echo "$line"; c=$(($c+1)); [ $c -lt 20 ] && continue; \
> 	read xxx <&3; c=0; \
> done
>
> should work - but seems to provoke a bug (and core dump!) in /bin/sh!
> But you can do:
>
> (exec 3<&0; dmesg | while read -r line; do \
> 	echo "$line"; c=$(($c+1)); [ $c -lt 20 ] && continue; \
> 	read xxx <&3; c=0; \
> done)

Both variants should work but they aren't obvious nor elegant, are they ? :) 
Too much of code. Maybe i'm not so experienced in managing Unix stations and 
i'm ready to admit this, but in 99% of cases i need something a bit more 
simplier and ready to use..

Ok, if there are strong objections against adding less or equivalent utility 
in /rescue, maybe for compromise put there some of above scripts ?

> The other option is to mount / and /usr then chroot to /

Of course i would if i had a healthy /usr partition. The task was to recover 
it after crash.

// wbr