Awesome, thanks for this tip!

On Wed, Dec 7, 2016 at 8:44 AM Greg Wooledge <wool...@eeg.ccf.org> wrote:

> On Wed, Dec 07, 2016 at 12:56:00AM +0000, Daniel Einspanjer wrote:
> > echo The desired output is:
> > echo "var = \"test test\""
>
> imadev:~$ q=\"
> imadev:~$ var="a variable"
> imadev:~$ cat <<EOF
> > ${var:+var = $q$var$q}
> > EOF
> var = "a variable"
> imadev:~$ echo "$BASH_VERSION"
> 4.4.0(1)-release
>
> Putting literal quotes (to be echoed) inside variables helps work around
> a fairly large number of tricky situations like this.  It's a useful
> general-purpose hack to keep in the back of your mind for the future.
>

Reply via email to