Setting path variable with a space.

Hi I am using MKS Toolkit c shell.

I am trying to set a path variable something like c:/Program Files/blah/blah

so

set path=(c:/Program Files/blah/blah)

this, however, does not work as it splits this thing up into 'c:/Program' and
'Files/blah/blah'.

Does anyone have any ideas on how to fix this issue. Perhaps some simple little hack??

Thank you!

Have you tried escaping the space with a backslash? e.g.,

set path=(c:/Program\ Files/blah/blah)

yes I tried that it didnt work for me...:frowning:

Have you tried... two backslashes? I'm serious.

Ha ya I thought the same thing. The first one is ignored and the second one remains. The space is not escaped and is intepreted at a type of seperator for the next variable. I'm trying different things right now. I think there is something to do with the actual PATH vs path vd ${PATH} im not sure just trying things

Are you sure that that 'path' variable is supposed to be set as an array?

1 Like

Ya I am almost positive its suppose to be set like this. But! I actually found the problem...well at least theoretically.
You were right the \ does work to espace the character it just that something is going wrong somewhere else in my script where it sources something which sets something idk i'll have to look into this.
Thanks

---------- Post updated at 03:37 PM ---------- Previous update was at 03:17 PM ----------

OKay so I figured out the problem but I do not have a solution.

Basically when you do this

set path=($path c:/Program\ Files/blah/blah)

it works completely fine, no problems.
BUT! the next time you add a path it will interpret blank spaces as a new variable start.
so if i do

set path=($path c:/doagain)

then the previous path formatting gets messed up!

please help! any ideas??

Try C:/PROGRA~2/blah/blah

O wow ya that worked like a charm. it was PROGRA~1 for me but it worked well.
btw do you know where those initial PATH variables come from the shell has before I even source any script? I'd like to take those out without PROGRA~1 since Ill have to re do that anyways.

In windows, it's found under your System Properties, in the Advanced tab, in the button 'Environment Variables' button.

On Unix, it's defined usually in the /etc/environment file and subsequent files for their shells, such as /etc/profile, /etc/bashrc, ~/.bashrc ~/.profile, among other locations.

1 Like