[prev in list] [next in list] [prev in thread] [next in thread]
List: bash-bug
Subject: Re: Yet another quoting question
From: DJ Mills <danielmills1 () gmail ! com>
Date: 2011-05-06 16:07:52
Message-ID: BANLkTi=4RF_t4axNum7CtDaD7DLB1xiqFQ () mail ! gmail ! com
[Download RAW message or body]
On Fri, May 6, 2011 at 12:00 PM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> On Fri, May 06, 2011 at 11:50:34AM -0400, Chet Ramey wrote:
> > Eric suggested %q, and that works to a
> > certain degree, but you can also use
> >
> > printf '"%s" ' "${vals[@]}" ; echo
> >
> > and get the double-quoting you want.
>
> Fails horribly if the array elements contain double quotes of their own.
>
> Realistically, I do NOT advise even attempting this. Do not try to write
> general functions that operate on arrays, passed by name. Bash truly
> does not have the tool set to cope with this. I can't stress this
> strongly enough.
>
>
The only possible way I can think of to do this safely in bash is to do
something like:
eval "printf '%s\0' \"\${$1[@]}\""
and then loop over the NUL-delimited output.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic