Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11934
| Path | csiph.com!xmission!news.glorb.com!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: An array variable created by export/readonly builtins inside a function becomes a locale variable to that function unexpectedly |
| Date | Mon, 30 Nov 2015 08:29:09 -0500 |
| Lines | 12 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.1007.1448890189.31583.bug-bash@gnu.org> (permalink) |
| References | <70266BC6-C65A-4D95-B7C1-2F63F3C45DEF@qq.com> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Trace | usenet.stanford.edu 1448890189 15009 208.118.235.17 (30 Nov 2015 13:29:49 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | bug-bash@gnu.org |
| To | ziyunfei <446240525@qq.com> |
| Envelope-to | bug-bash@gnu.org |
| Content-Disposition | inline |
| In-Reply-To | <70266BC6-C65A-4D95-B7C1-2F63F3C45DEF@qq.com> |
| User-Agent | Mutt/1.4.2.3i |
| X-detected-operating-system | by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] |
| X-Received-From | 139.137.100.1 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.14 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <http://lists.gnu.org/archive/html/bug-bash> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| Xref | csiph.com gnu.bash.bug:11934 |
Show key headers only | View raw
On Sat, Nov 28, 2015 at 11:18:24AM +0800, ziyunfei wrote:
> $ bash -c 'foo() { readonly a=(1);echo a=$a; }; foo; echo a=$a' # a becomes a local variable
> a=1
> a=
"readonly" is a synonym for "declare -r", and declare (without the -g
option) always marks variables as local when used in a function.
If you want variables created in a function NOT to be local to that
function, you must skip all declarations entirely. Just create the
variable by assigning to it.
Back to gnu.bash.bug | Previous | Next | Find similar
Re: An array variable created by export/readonly builtins inside a function becomes a locale variable to that function unexpectedly Greg Wooledge <wooledg@eeg.ccf.org> - 2015-11-30 08:29 -0500
csiph-web