bug-bash
[Top][All Lists]
Advanced

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

Re: 4.2 error: processing command substitution within arithmetic operati


From: Rui Santos
Subject: Re: 4.2 error: processing command substitution within arithmetic operation
Date: Tue, 28 Jun 2011 10:15:53 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; pt-PT; rv:1.9.2.4) Gecko/20100608 SUSE/3.1.0 Thunderbird/3.1

 On 24-06-2011 21:01, Greg Wooledge wrote:
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
here.

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.
Hi Greg. Thanks for your reply.
I was not aware of that. It will be remembered for future scripts. I do, however, have legacy concerns to take care of and thus, I will need it to work on this cases.

Thanks.
So:

imadev:~$ array[$(echo -n 1001) - 1001]=1
imadev:~$ set | grep array=
array=([0]="1")
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
better.



--
Regards,
Rui Santos




reply via email to

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