It is currently Tue, 30 Nov 2021 17:48:19 GMT



 
Author Message
 help defining csh alias
I have a csh variable that contains an array of strings and would like to
print it as an ordered, numbered list.  For reasons I don't understand the
following doesn't work:

alias listd 'set c = 1; foreach n ($dmarks); echo "$c : $n"; @ c = $c + 1; end'

When executed, the end is apparently ignored and I get a single iteration.
Interactively, the following works

perl -e '$c = 1; while (@ARGV) {printf "%02d : %s\n",$c,shift; ++$c;}' $dmarks

I want to put it in an alias.  The following doesn't work:

alias listd 'perl -e \'$c = 1; while (@ARGV) {printf "%02d : %s\n",$c,shift; ++$c;}\' $dmarks'

I get an "Unmatched '." error message when I try to define the alias.  I've
tried various combinations of escaped and unescaped " and ' pairs but
with no luck.  Any guidance out there?

thanks,
Richard Hargrove
+-----------------------------------------------------------------------------+
| USPS: Convex Computer Corp.                             phone: 214/497-4323 |
|       3000 Waterview Pkwy.                                fax: 214/497-4441 |
|       Richardson, TX 75080                         net: richa...@convex.com |
+-----------------------------------------------------------------------------+



 Mon, 11 Sep 1995 22:56:55 GMT   
 help defining csh alias

The \ escape does not seem to work within single (or double) quotes.  Try this:

echo '\'

You get \, but you'd get "Unmatched '." if the second tick were escaped.
Use this:

alias listd 'perl -e' \''$c = 1; while (@ARGV) {printf "%02d : %s\n",$c,shift; ++$c;}'\'' $dmarks'

The escaped ticks are all outside of the unescaped ticks.
--
Danny Faught, Convex rookie
"Using a computer should always be easier than not using a computer."
                                                                - Ted Nelson



 Tue, 12 Sep 1995 01:29:37 GMT   
 help defining csh alias
: alias listd 'perl -e \'$c = 1; while (@ARGV) {printf "%02d : %s\n",$c,shift; ++$c;}\' $dmarks'
:
: I get an "Unmatched '." error message when I try to define the alias.  I've
: tried various combinations of escaped and unescaped " and ' pairs but
: with no luck.  Any guidance out there?

In csh you often have to say '"'"' when you mean \'.

Larry Wall
lw...@netlabs.com



 Wed, 13 Sep 1995 03:29:40 GMT   
 
   [ 3 post ] 

Similar Threads

1. gcc #define #define #define


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software