Re: Obscure test failures on DilOS (OpenSolaris-like) with 8.22.157-1b24
From:
Eric Blake
Subject:
Re: Obscure test failures on DilOS (OpenSolaris-like) with 8.22.157-1b243
Date:
Fri, 18 Jul 2014 19:38:57 -0600
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
On 07/18/2014 06:03 PM, Assaf Gordon wrote:
>
> $ /bin/sh -c 'test() { local i=1 ; echo $i ; } ; test'
> /bin/sh[1]: local: not found [No such file or directory]
>
'local' is not a POSIX shell construct. It is not portable to write
/bin/sh scripts and expect local to work. The workaround is simple -
don't use local variables, and just be sure to namespace your variables
so that your functions don't inadvertently collide with the rest of your
script.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc Description: OpenPGP digital signature