* quoting words
@ 2021-09-28 11:35 Pier Paolo Grassi
2021-09-28 11:38 ` Pier Paolo Grassi
0 siblings, 1 reply; 9+ messages in thread
From: Pier Paolo Grassi @ 2021-09-28 11:35 UTC (permalink / raw)
To: Zsh-Users List
[-- Attachment #1: Type: text/plain, Size: 351 bytes --]
Hello, I have something like
a=('aa bb' 'cc dd');
and I would like to get the quoted representation inside a string, so that
echo -e $b
'aa bb' 'cc dd'
or that
typeset -p b
gives
'''aa bb'' ''cc dd'''
I tried with
a=(sa\ bb cc\ dd); b="${(q+)a[@]}"; typeset -p b
typeset b='''sa bb cc dd'''
and other inconclusive variations
Pier Paolo Grassi
[-- Attachment #2: Type: text/html, Size: 896 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: quoting words
2021-09-28 11:35 quoting words Pier Paolo Grassi
@ 2021-09-28 11:38 ` Pier Paolo Grassi
2021-09-28 12:19 ` Marc Chantreux
2021-09-28 16:04 ` Bart Schaefer
0 siblings, 2 replies; 9+ messages in thread
From: Pier Paolo Grassi @ 2021-09-28 11:38 UTC (permalink / raw)
To: Zsh-Users List
[-- Attachment #1: Type: text/plain, Size: 664 bytes --]
I think I found a way
a=(sa\ bb cc\ dd); a=${(qq@)"${a[@]}"}; typeset -p a; echo -e $a
typeset a='''sa bb'' ''cc dd'''
'sa bb' 'cc dd'
sorry for the bother
Pier Paolo Grassi
Il giorno mar 28 set 2021 alle ore 13:35 Pier Paolo Grassi <
pierpaolog@gmail.com> ha scritto:
> Hello, I have something like
> a=('aa bb' 'cc dd');
>
> and I would like to get the quoted representation inside a string, so that
>
> echo -e $b
> 'aa bb' 'cc dd'
>
> or that
>
> typeset -p b
> gives
> '''aa bb'' ''cc dd'''
>
> I tried with
>
> a=(sa\ bb cc\ dd); b="${(q+)a[@]}"; typeset -p b
> typeset b='''sa bb cc dd'''
>
> and other inconclusive variations
>
> Pier Paolo Grassi
>
[-- Attachment #2: Type: text/html, Size: 1710 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: quoting words
2021-09-28 11:38 ` Pier Paolo Grassi
@ 2021-09-28 12:19 ` Marc Chantreux
2021-09-28 20:10 ` Pier Paolo Grassi
2021-09-28 16:04 ` Bart Schaefer
1 sibling, 1 reply; 9+ messages in thread
From: Marc Chantreux @ 2021-09-28 12:19 UTC (permalink / raw)
To: Pier Paolo Grassi; +Cc: Zsh-Users List
hello,
echo $ZSH_VERSION
omz=( 'the first' 'the last' )
echo a isa ${(t)omz}
typeset -p omz
echo -e "${(@qq)omz}"
gives me
5.8
a isa array
typeset -a omz=( 'the first' 'the last' )
'the first' 'the last'
note the -a when you have
typeset a='''sa bb'' ''cc dd'''
so ${(t)omz} is probably scalar. would you mind unset a and give
my code a try ?
regards
marc
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: quoting words
2021-09-28 12:19 ` Marc Chantreux
@ 2021-09-28 20:10 ` Pier Paolo Grassi
0 siblings, 0 replies; 9+ messages in thread
From: Pier Paolo Grassi @ 2021-09-28 20:10 UTC (permalink / raw)
To: Marc Chantreux; +Cc: Zsh-Users List
[-- Attachment #1: Type: text/plain, Size: 878 bytes --]
Hello, here is the output:
5.8
a isa array
typeset -a omz=( 'the first' 'the last' )
'the first' 'the last'
the result from your script is in fact correct if I assign the
"${(@qq)omz}":
typeset -a omz=( 'the first' 'the last' )
a="${(@qq)omz}"
typeset -p a
typeset a='''the first'' ''the last'''
regards
Pier Paolo Grassi
Il giorno mar 28 set 2021 alle ore 20:31 Marc Chantreux <
mc@prometheus.u-strasbg.fr> ha scritto:
> hello,
>
> echo $ZSH_VERSION
> omz=( 'the first' 'the last' )
> echo a isa ${(t)omz}
> typeset -p omz
> echo -e "${(@qq)omz}"
>
> gives me
>
> 5.8
> a isa array
> typeset -a omz=( 'the first' 'the last' )
> 'the first' 'the last'
>
> note the -a when you have
>
> typeset a='''sa bb'' ''cc dd'''
>
> so ${(t)omz} is probably scalar. would you mind unset a and give
> my code a try ?
>
> regards
> marc
>
>
>
[-- Attachment #2: Type: text/html, Size: 1835 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: quoting words
2021-09-28 11:38 ` Pier Paolo Grassi
2021-09-28 12:19 ` Marc Chantreux
@ 2021-09-28 16:04 ` Bart Schaefer
2021-09-28 19:54 ` Pier Paolo Grassi
1 sibling, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 2021-09-28 16:04 UTC (permalink / raw)
To: Pier Paolo Grassi; +Cc: Zsh-Users List
On Tue, Sep 28, 2021 at 4:39 AM Pier Paolo Grassi <pierpaolog@gmail.com> wrote:
>
> a=(sa\ bb cc\ dd); a=${(qq@)"${a[@]}"}; typeset -p a; echo -e $a
It should be sufficient to do
a=${(qqq)a}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: quoting words
2021-09-28 16:04 ` Bart Schaefer
@ 2021-09-28 19:54 ` Pier Paolo Grassi
2021-09-28 20:09 ` Lawrence Velázquez
0 siblings, 1 reply; 9+ messages in thread
From: Pier Paolo Grassi @ 2021-09-28 19:54 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Zsh-Users List
[-- Attachment #1: Type: text/plain, Size: 417 bytes --]
on 5-8 I get:
> a=(sa\ bb cc\ dd); a=${(qqq)a}
> typeset -p a
typeset a='"sa bb cc dd"'
Pier Paolo Grassi
Il giorno mar 28 set 2021 alle ore 18:04 Bart Schaefer <
schaefer@brasslantern.com> ha scritto:
> On Tue, Sep 28, 2021 at 4:39 AM Pier Paolo Grassi <pierpaolog@gmail.com>
> wrote:
> >
> > a=(sa\ bb cc\ dd); a=${(qq@)"${a[@]}"}; typeset -p a; echo -e $a
>
> It should be sufficient to do
>
> a=${(qqq)a}
>
[-- Attachment #2: Type: text/html, Size: 1104 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: quoting words
2021-09-28 19:54 ` Pier Paolo Grassi
@ 2021-09-28 20:09 ` Lawrence Velázquez
2021-09-28 20:10 ` Pier Paolo Grassi
2021-09-28 20:32 ` Bart Schaefer
0 siblings, 2 replies; 9+ messages in thread
From: Lawrence Velázquez @ 2021-09-28 20:09 UTC (permalink / raw)
To: Pier Paolo Grassi, Bart Schaefer; +Cc: zsh-users
On Tue, Sep 28, 2021, at 3:54 PM, Pier Paolo Grassi wrote:
> on 5-8 I get:
>
>> a=(sa\ bb cc\ dd); a=${(qqq)a}
>> typeset -p a
> typeset a='"sa bb cc dd"'
Perhaps it should have been ${(qqq@)a}?
% a=(sa\ bb cc\ dd); typeset -p a
typeset -a a=( 'sa bb' 'cc dd' )
% b=${(qqq@)a}; typeset -p b
typeset b='"sa bb" "cc dd"'
--
vq
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: quoting words
2021-09-28 20:09 ` Lawrence Velázquez
@ 2021-09-28 20:10 ` Pier Paolo Grassi
2021-09-28 20:32 ` Bart Schaefer
1 sibling, 0 replies; 9+ messages in thread
From: Pier Paolo Grassi @ 2021-09-28 20:10 UTC (permalink / raw)
To: Lawrence Velázquez; +Cc: Bart Schaefer, Zsh-Users List
[-- Attachment #1: Type: text/plain, Size: 595 bytes --]
yes this works fine:
a=(sa\ bb cc\ dd); a=${(qqq@)a}; typeset -p a
typeset a='"sa bb" "cc dd"'
Pier Paolo Grassi
Il giorno mar 28 set 2021 alle ore 22:09 Lawrence Velázquez <larryv@zsh.org>
ha scritto:
> On Tue, Sep 28, 2021, at 3:54 PM, Pier Paolo Grassi wrote:
> > on 5-8 I get:
> >
> >> a=(sa\ bb cc\ dd); a=${(qqq)a}
> >> typeset -p a
> > typeset a='"sa bb cc dd"'
>
> Perhaps it should have been ${(qqq@)a}?
>
> % a=(sa\ bb cc\ dd); typeset -p a
> typeset -a a=( 'sa bb' 'cc dd' )
> % b=${(qqq@)a}; typeset -p b
> typeset b='"sa bb" "cc dd"'
>
> --
> vq
>
[-- Attachment #2: Type: text/html, Size: 1259 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: quoting words
2021-09-28 20:09 ` Lawrence Velázquez
2021-09-28 20:10 ` Pier Paolo Grassi
@ 2021-09-28 20:32 ` Bart Schaefer
1 sibling, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 2021-09-28 20:32 UTC (permalink / raw)
To: Lawrence Velázquez; +Cc: Pier Paolo Grassi, Zsh Users
On Tue, Sep 28, 2021 at 1:09 PM Lawrence Velázquez <larryv@zsh.org> wrote:
>
> Perhaps it should have been ${(qqq@)a}?
Yes, typo on my part, sorry.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-09-28 20:33 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 11:35 quoting words Pier Paolo Grassi
2021-09-28 11:38 ` Pier Paolo Grassi
2021-09-28 12:19 ` Marc Chantreux
2021-09-28 20:10 ` Pier Paolo Grassi
2021-09-28 16:04 ` Bart Schaefer
2021-09-28 19:54 ` Pier Paolo Grassi
2021-09-28 20:09 ` Lawrence Velázquez
2021-09-28 20:10 ` Pier Paolo Grassi
2021-09-28 20:32 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).