Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!ucsd!sdcsvax!trantor.harris-atd.com!x102c.harris-atd.com!bbadger From: bbadger@x102c.harris-atd.com (Badger BA 64810) Newsgroups: comp.unix.wizards Subject: csh variable syntax '${x1[2]}' is broken. Keywords: unix, csh, variable, substitution, bug Message-ID: <1893@trantor.harris-atd.com> Date: 5 Apr 89 15:29:37 GMT Sender: news@trantor.harris-atd.com Reply-To: bbadger@x102c.harris-atd.com (Badger BA 64810) Organization: Harris GISD, Melbourne, FL Lines: 74 Variable expansion in csh isn't done properly. The problem is shown by this example: % set verbose set verbose set verbose % set x1=(a b c) set x1= ( a b c ) % echo ${x1[2]} echo 1${x[2]} Variable syntax. % Here's a more complete transcript, showing that a variable name with no digits in it works correctly: % set echo % set verbose set verbose % set xx=(a b c) set xx= ( a b c ) set xx= ( a b c ) % set x1=(d e f) set x1= ( d e f ) set x1= ( d e f ) % alias x 'echo ${x\!:1[2]}' alias x 'echo ${x!:1[2]}' alias x echo ${x!:1[2]} % alias x_ 'echo $x\!:1[2]' alias x_ 'echo $x!:1[2]' alias x_ echo $x!:1[2] % echo ${xx[2]} echo ${xx[2]} echo b b % x x x x echo b b % echo $xx[2] echo $xx[2] echo b b % x_ x x_ x echo b b % echo $x1[2] echo $x1[2] echo e e % x_ 1 x_ 1 echo e e % echo ${x1[2]} echo 1${x[2]} Variable syntax. % !! echo 1${x[2]} x: Undefined variable. % x 1 x 1 Variable syntax. % !! x 1 Variable syntax. % The work-around seems to be to not use {}'s. Bernard A. Badger Jr. 407/984-6385 |``Use the Source, Luke!'' Secure Computer Products |``Get a LIFE!'' -- J.H. Conway Harris GISD, Melbourne, FL 32902 |Buddy, can you paradigm? Internet: bbadger%x102c@trantor.harris-atd.com|'s/./&&/g' Tom sed expansively.