[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: indirect parameter expansion broken for ${#PARAM}
From: |
Chet Ramey |
Subject: |
Re: indirect parameter expansion broken for ${#PARAM} |
Date: |
Thu, 12 Jul 2001 11:03:18 -0400 |
> Machine Type: i386-pc-linux-gnu
>
> Bash Version: 2.03
> Patch Level: 0
> Release Status: release
>
> Description:
>
> Indirect parameter expansion (i.e. of the form ${!var}) seems to be
> broken in bash 2.03 when used in the ${#var} form to obtain the length
> of a variable's value.
It's never worked like that. The `!' must appear immediately after
the `{' to be recognized. Do it in two steps, with an intermediate
variable.
> Repeat-By:
>
> # the following should print "3", instead it causes an error:
>
> myvar=val
> myvarname=myvar
> echo ${#!myvarname}
> bash: !myvarname}: event not found
myvar=val
myvarname=myvar
tmpvar=${!myvarname}
echo ${#tmpvar}
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)
Chet Ramey, CWRU chet@po.CWRU.Edu http://cnswww.cns.cwru.edu/~chet/