This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: $USER is not resolved in paths sometimes


Thomas Deinhamer writes:
> I'm running Cygwin and using the zsh shell.
>
> In the .zshrc file I got these lines:
> alias vboxmanage=VBoxManage
> vboxmanage setproperty machinefolder "C:\Users\$USER\VirtualBox VMs\"

You really should not use DOS paths, but if you do you should know when
they will be expanded by the shell and how often, in which case you need
to escape the backslashes accordingly.

> When I try to boot a VM using vagrant (which
> uses vboxmanage internally I think) sometimes
> $USER is not resolved to the real username.
>
> Instead vboxmanage creates a new machinefolder
> on C:/ which is then called "Users$USER" and
> inside this folder there is the folder "VirtualBox VMs",
> so the wrong path is "C:\Users$USER\VirtualBox VMs\".

No, that's exactly what you told it to create, "\$" means "insert a
literal "$".

> How could that be? Sometimes it works, sometimes it doesn't.

I don't see how the example you gave can work correctly, not even
sometimes, unless vboxmanage does interpret $USER itself (or expands its
arguments using a shell or something like that).  Which is exactly why
you shouldn't use this sort of path in the first place, since how much
escaping needs to be done depends on how many evaluations the string
goes through.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Samples for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]