bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash' code to store string of any characters containing pair of "" a


From: Dale R. Worley
Subject: Re: Bash' code to store string of any characters containing pair of "" and '' at once
Date: Wed, 25 Dec 2024 11:42:41 -0500

Greg Wooledge <greg@wooledge.org> writes:
>> You need to escape one of the types of quotes. Double quotes is
>> generally simpler:
>> 
>> $ x="foo \"foo\" and 'bar' content"
>> $ echo "$x"
>> foo "foo" and 'bar' content
>
> Only in this restricted case.  Using double quotes as the outer layer
> means you have to backslash-escape *lots* of other characters inside
> the payload: double quotes, dollar signs, backticks, and backslashes
> at the very minimum.

My understanding is that the double-quote method is traditional, having
been around for decades.  Though that works uniformly only in scripts,
where history expansion is off by default.  But it's well-known that the
characters you need to quote inside double quotes are *exactly* double
quotes, dollar signs, backticks, and backslashes.

Dale



reply via email to

[Prev in Thread] Current Thread [Next in Thread]