csh variable syntax '${x1[2]}' is broken.
Badger BA 64810
bbadger at x102c.harris-atd.com
Thu Apr 6 01:29:37 AEST 1989
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 at trantor.harris-atd.com|'s/./&&/g' Tom sed expansively.
More information about the Comp.unix.wizards
mailing list