[net.unix-wizards] C-shell puzzles

drs@bnl.UUCP (David R. Stampf) (11/14/85)

For all of you C-shell fans - heres a couple of bugs/puzzles.  (I don't know
the answer to the second.)

The following alias should give a directory listing of the files which have a
specified pattern in the middle.  It only works if the pattern is at the end.

	alias lm 'ls -l *\!**'

Its easy to make it work, but I think that the above is acceptable.

The next has to do with how do you run a command which has nested command
substitutions?  From what I can see, you cannot.  I would love to be able
to type (in a more complicated shell script and using any amount of quoting
necessary)

	echo `echo `date``

but no amount of quoting seems to satisfy the shell.  Any ideas?  (I know -
RTFM, but I have grepped sh and csh for nest, recurs, ... and have come up
empty.)  Any suggestions would be appreciated.  Both problems exist on
Suns and Ultrix 1.0.

avolio@decuac.UUCP (Frederick M. Avolio) (11/17/85)

It is not clear to me that either is a bug. Perhaps it would be easier to
address any questions if you indicated what you really wanted to do.  For
example, using the eval "command"  (as in  "echo `eval date`") might do
what you want, but since you really didn't say...
-- 
Fred @ DEC Ultrix Applications Center    {decvax,seismo,cbosgd}!decuac!avolio

tim@ISM780B.UUCP (11/21/85)

Here's another good C shell quirk:

	$ echo foo
	foo
	$ repeat 3 echo foo
	foo
	foo
	foo
	$ repeat 3 repeat 3 echo foo
	foo
	foo
	foo
	foo
	foo
	$ repeat $N repeat $M echo foo        # $N and $M are integers
	[ $N + $M - 1 foo's ]
	$ repeat $N1 repeat $N2 ... repeat $Nk echo foo
	[ $N1 + $N2 + ... + $Nk - k + 1 foo's ]
	$

						Tim Smith
						ihnp4!cithep!tim
						ima!ism780!tim