Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11678
| Path | csiph.com!xmission!news.glorb.com!usenet.stanford.edu!not-for-mail |
|---|---|
| From | isabella parakiss <izaberina@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | problem with @A and arrays |
| Date | Sat, 17 Oct 2015 02:55:21 +0200 |
| Lines | 48 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.487.1445043402.7904.bug-bash@gnu.org> (permalink) |
| NNTP-Posting-Host | lists.gnu.org |
| X-Trace | usenet.stanford.edu 1445043403 25018 208.118.235.17 (17 Oct 2015 00:56:43 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | bug-bash@gnu.org |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:to:subject; bh=Jz0TnOg9tku93X+jtOgB2Jtn9w3DUK+5qD5lMy070Kg=; b=YTqD7WXD0hmtjy2DJXDXHPq4RkEP9XRSxF4w6TN0erbkua37hZXikWmLAaq6uzT+PV YKxX/qP+MI4sv5+Z0tu4LloBwiyqinYu35uARlqjzindkZ9FnbeCjoxYBvS+N+heLOA7 WVT6TPmXNn1si+fHPjdtsOXiPF2kuOHjoRq3B3igT1NI3Q0f64XZyyaFeBAV3LnPj9Eh NpHOln+7gBUI3lj/5YUsOKQfyYOxCc00SFn+xDuZBo9HtThhvm6h5MHuVRJm3Va97sUf KquxOffziHP3VnjsgNtdXQ3/JoByKGH052Zvgn5lJZWNg7Vl37HoaRMycFSzDoHk2jh4 wu9A== |
| X-Received | by 10.180.93.133 with SMTP id cu5mr7487970wib.49.1445043395864; Fri, 16 Oct 2015 17:56:35 -0700 (PDT) |
| X-detected-operating-system | by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). |
| X-Received-From | 2a00:1450:400c:c05::230 |
| 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:11678 |
Show key headers only | View raw
${array[@]@A} splits the values.
$ a=("a b" "c d"); printf "<%s>" "${a[@]@A}"
<declare><-a><a=([0]="a><b"><[1]="c><d")>
diff --git a/subst.c b/subst.c
index 2a7366f..d7258b8 100644
--- a/subst.c
+++ b/subst.c
@@ -4796,18 +4796,26 @@ array_var_assignment (v, itype, quoted)
{
char *ret, *val, flags[MAX_ATTRIBUTES];
int i;
+ ARRAY *a;
+ HASH_TABLE *h;
+ WORD_LIST *list;
if (v == 0)
return (char *)NULL;
- val = array_p (v) ? array_to_assign (array_cell (v), 0)
- : assoc_to_assign (assoc_cell (v), 0);
- if (val == 0)
+ a = (v && array_p (v)) ? array_cell (v) : 0;
+ h = (v && assoc_p (v)) ? assoc_cell (v) : 0;
+
+ list = a ? array_to_word_list (a) : (h ? assoc_to_word_list (h) : 0);
+ if (list == 0)
{
val = (char *)xmalloc (3);
val[0] = '(';
val[1] = ')';
val[2] = 0;
}
+ else
+ val = list_transform ('Q', (SHELL_VAR *)0, list, itype, quoted);
+ dispose_words (list);
i = var_attribute_string (v, 0, flags);
ret = (char *)xmalloc (i + strlen (val) + strlen (v->name) + 16);
sprintf (ret, "declare -%s %s=%s", flags, v->name, val);
---
xoxo iza
Back to gnu.bash.bug | Previous | Next | Find similar
problem with @A and arrays isabella parakiss <izaberina@gmail.com> - 2015-10-17 02:55 +0200
csiph-web