[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Inconsistent quote and escape handling in substitution part of param
From: |
Greg Wooledge |
Subject: |
Re: Inconsistent quote and escape handling in substitution part of parameter expansions. |
Date: |
Tue, 28 Feb 2012 11:01:58 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Tue, Feb 28, 2012 at 04:52:48PM +0100, John Kearney wrote:
> The standard work around you see is
> echo -n \'${1//\'/\'\\\'\'}\'" "
> but its not the same thing
Workaround for what? Not the same thing as what? What is this pile
of punctuation attempting to do?
> # why does this work, this list was born of frustration, I tried
> everything I could think of.
> echo \'${test//"'"/\'\\\'\'}\'" "
> 'weferfds'\''dsfsdf'
Are you trying to produce "safely usable" strings that can be fed to
eval later? Use printf %q for that.
imadev:~$ input="ain't it * a \"pickle\"?"
imadev:~$ printf '%q\n' "$input"
ain\'t\ it\ \*\ a\ \"pickle\"\?
printf -v evalable_input %q "$input"
Or, y'know, avoid eval.
Or is this something to do with sed? Feeding strings to sed when you
can't choose a safe delimiter? That would involve an entirely different
solution. It would be nice to know what the problem is.
- Inconsistent quote and escape handling in substitution part of parameter expansions., lhunath, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Roman Rakus, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Chet Ramey, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Roman Rakus, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., John Kearney, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions.,
Greg Wooledge <=
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., John Kearney, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Greg Wooledge, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Roman Rakus, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Roman Rakus, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Greg Wooledge, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Roman Rakus, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Dan Douglas, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., John Kearney, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., Dan Douglas, 2012/02/28
- Re: Inconsistent quote and escape handling in substitution part of parameter expansions., John Kearney, 2012/02/28