[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 4.2 error: processing command substitution within arithmetic operati

From: Greg Wooledge
Subject: Re: 4.2 error: processing command substitution within arithmetic operation
Date: Fri, 24 Jun 2011 16:01:02 -0400
User-agent: Mutt/

On Fri, Jun 24, 2011 at 06:18:08PM +0100, Rui Santos wrote:
> Try this script:
> #!/bin/bash
> declare -ax array
> array[$(( $( echo -n 1001 ) - 1001 ))]=1
> this will issue an error: line 6: 1001: command not found

imadev:~$ unset array
imadev:~$ array[$(( $( echo -n 1001 ) - 1001 ))]=1
imadev:~$ unset array
bash: 1001: command not found

And similar... hmm, this is beyond weird.  I have no idea what's happening

But if you want to work around the problem, I would suggest simplifying
things.  For starters, you do not need $((...)) inside an array index
because the [...] already introduce a math context.


imadev:~$ array[$(echo -n 1001) - 1001]=1
imadev:~$ set | grep array=
imadev:~$ unset array

And that assumes you need to keep the command substitution for some
unstated reason.  If you can get rid of that too, that would be even

reply via email to

[Prev in Thread] Current Thread [Next in Thread]