Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux Pacman Development (http://www.linux-archive.org/archlinux-pacman-development/)
-   -   makepkg bash-3.2 issue (http://www.linux-archive.org/archlinux-pacman-development/484526-makepkg-bash-3-2-issue.html)

Dave Reisner 02-02-2011 11:44 PM

makepkg bash-3.2 issue
 
On Thu, Feb 03, 2011 at 10:33:45AM +1000, Allan McRae wrote:
> Hi,
>
> Can anyone give me a fix for this:
>
>
> local optdepends_list
> eval $(awk '/^[[:space:]]*optdepends=/,/)/' "$BUILDFILE" | sed
> "s/optdepends=/optdepends_list+=/")
>
> In bash-3.2, this gives optdepends_list with "" as the first item in
> the array. It appears that declaring a local variable in bash-3.2
> causes it to be given a blank value:
>
> bash-4.1
> > declare optdepends_list
> > echo ${#optdepends_list[@]}
> 0
>
> bash-3.2
> > declare optdepends_list
> > echo ${#optdepends_list[@]}
> 1
>
>
> Anyone know how to work around this?
>
> Allan
>

Sure, just initialize the array as empty.

$ declare foo=()
$ echo ${#foo[@]}

dave

Allan McRae 02-03-2011 12:00 AM

makepkg bash-3.2 issue
 
On 03/02/11 10:44, Dave Reisner wrote:

On Thu, Feb 03, 2011 at 10:33:45AM +1000, Allan McRae wrote:

Hi,

Can anyone give me a fix for this:


local optdepends_list
eval $(awk '/^[[:space:]]*optdepends=/,/)/' "$BUILDFILE" | sed
"s/optdepends=/optdepends_list+=/")

In bash-3.2, this gives optdepends_list with "" as the first item in
the array. It appears that declaring a local variable in bash-3.2
causes it to be given a blank value:

bash-4.1

declare optdepends_list
echo ${#optdepends_list[@]}

0

bash-3.2

declare optdepends_list
echo ${#optdepends_list[@]}

1


Anyone know how to work around this?

Allan



Sure, just initialize the array as empty.

$ declare foo=()
$ echo ${#foo[@]}



Of course... It all seems so simple now!

Thanks,
Allan


All times are GMT. The time now is 11:33 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.