[net.unix] Non-Gripes about /bin/sh

lvc@danews.UUCP (Larry Cipriani) (06/09/86)

I think you'll find that the shell is far more powerful
than the manual page would lead one to believe.  I've been
using it for 4 years and I'm still learning things about it.
I don't know about csh, as I've never used it.

The sh manual page describes how to do what you described
with multiple files in the Input/Output section.  Here
are some examples to make it more concrete.

	exec 3>&1	# make file descriptor 3 a duplicate of stdout

	exec >${filen}	# stdout now goes to $filen

	exec 2>${filen}	# stderr now goes to $filen

	exec 0<${filen}	# connect stdin to $filen
	while read line
	do
		stuff
	done

Also, consider:

	lu="ls -l /usr/spool/uucppublic"

Then,

	$lu	# type in the $ too.

will execute ls -l /usr/spool/uucppublic.  Is this what you wanted ?

If you have to do some trick substitutions in a command, try
eval.  Here is a small shell script that uucp's a list of files
to a predetermined location ($HOME/lvc/uucp) on another machine.

case ${#} in
   0|1)	echo "usage: ${0} filen, ..., filen machine" >&2 ; exit 1 ;;
     *)	eval "case \${$#} in
	    cbsc[acefghklmn]|danews) uucp ${*}!~lvc/uucp ;;
	    * ) echo ${0}: \${$#} invalid machine >&2 ; exit 1 ;;
	esac" ;;
esac

Hope this answers some of your questions.  There are some undocumented
features in the the shell, but you'll have enough work ahead of you
learning the documented ones first.

If you can get U of W to buy the code for the Korn Shell (only
$2000 for the source) it's well worth the money.
-- 

Larry Cipriani		AT&T Network Systems
danews!lvc		"Nothing is worse than an itch you can never scratch."

craig@comp.lancs.ac.uk (Craig Wylie) (06/11/86)

In article <133@danews.UUCP> lvc@danews.UUCP writes:
>I think you'll find that the shell is far more powerful
>than the manual page would lead one to believe.  I've been
>using it for 4 years and I'm still learning things about it.
>I don't know about csh, as I've never used it.
>
>   [Edited out shell script]
>
>If you can get U of W to buy the code for the Korn Shell (only
>$2000 for the source) it's well worth the money.

I would suggest that people try the msh from :

	...!mcvax!ukc!cl-jenny!mb		/* UUCP */

	mb%cam.cl@ucl.cs.ARPA

	mb@uk.ac.cam.cl				/* JANET */

mb is Mike Burrows.  

msh is a sh program with complete command line editing and
shell functions  and its  ----   FREE (or it was when I got a copy :-)).

I like it a lot, it runs on our vax (4.2BSD) with no problems and I am 
about to port it to a sun 2 (no problems here as it very nearly works anyway ).

A source license is required for the source,
although I think it is available as executable code as well,
and it is available for at least
4.2  S5 R? 2.9 ...


Craig.
-- 
UUCP:	 ...!seismo!mcvax!ukc!dcl-cs!craig| Post: University of Lancaster,
DARPA:	 craig%lancs.comp@ucl-cs          |	  Department of Computing,
JANET:	 craig@uk.ac.lancs.comp           |	  Bailrigg, Lancaster, UK.
Phone:	 +44 524 65201 Ext. 4146   	  |	  LA1 4YR
Project: Cosmos Distributed Operating Systems Research Group

andy@cheviot.newcastle.ac.uk (Andy Linton) (06/12/86)

We also run 'msh' and I would echo Craig Wylie's recommendation.
We have it on Sun 3 and  on Vaxen running 4.2 and 8th Edition.

It's nice!!

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SENDER 	: Andy Linton		PHONE	: +44 91 2329233
POST	: Computing Lab, University of Newcastle upon Tyne, UK, NE1 7RU
ARPA	: andy%cheviot.newcastle.ac.uk@ucl-cs.ARPA)
JANET	: andy@uk.ac.newcastle.cheviot
UUCP	: <UK>!ukc!cheviot!andy

***  Ni fui moran beagan d'aon rud, ach is fui moran beagan ceille.  ***