Q:

Spaces and curly braces for variables in bash

Is there a way to make ${VAR} expand as if it were quoted in double quotes?
That's not what I wanted to see:
% A="some spaces in there"
% touch ${A}
% ls -1
in
some
spaces
there

Sure, I can use typical notation like "$VAR". But that's cumbersome when using quotes within quoted text, etc. I wonder if there's a way of expanding ${...} notation that would treat ${...} as if it were "${...}" while not using doublequotes themselves?

A:

Not following accepted best practice (and learning how the shell really works) is very likely to bite you. Repeatedly. With zombie virus-infected fangs. Some things which can help:

You can use different quotes for different parts of a single parameter as long as the start and end quotes are next to each other:
$ printf '%q\n' "foo 'bar' baz"'nuu "boo" zoo'
foo\ \'bar\'\ baznuu\ \"boo\"\ zoo

You can set IFS in a subshell to avoid screwing up your entire script:
$ a="some spaces in there"
$ (IFS= && touch ${a})
$ ls -1
some spaces in there

