In my bash .profile
, I have a series of export
statements assigning names to commonly used directories. Some of these directories have spaces in the path
and are causing problems, because of the way bash treats the spaces.
I know I can use quotes at the bash prompt to solve this problem:
cd "$mydir"
I am looking for a better way: can I change the export statements themselves within the .profile
script to do this more tidily, and avoid the need for the quotation marks at the prompt? I have tried escaping the spaces with backslashes, ticks, multiple quotation marks, everything .... but no success.
I am using "Terminal.app" on OS X 10.9
There's nothing you can do in the export
command to fix this. This is just how bash
expands variables. If the variable is not in quotes, it performs word splitting and wildcard expansion on the result.