-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bash unable to reference "${PROGRAMFILES(X86)}" #43
Comments
|
I'm not entirely sure what you're doing there. Maybe you want: That does something. |
|
Thanks, but that will expand to the same string - to give the background on these two variables: The reason I say typically, is that there could be some strange virtual instance that has the registry configured for those variables to point to "D:\Program Files" or "K:\Program Files" I'm trying to pragmatically discover where a specific application is installed regardless if it is XP, or WOW64 or 64/64 mode. By expanding "${PROGRAMFILES}" "${PROGRAMFILES(X86)}" it will allow me to search the Install location regardless of what Windows version the user installed and regardless of the application installed being 32bit or 64bit version. As a side - I've tried "${PROGRAMFILES(X86)}" and "${PROGRAMFILES(X86)}" and "${PROGRAMFILES(X86)}" - one idea I can try in the morning is "${'PROGRAMFILES(X86)'}" |
|
I see, the environment variable name contains brackets. Unfortunately both POSIX and bash only allow letters, digits or underscores in shell variable names. I think this means that it isn't possible to reference an environment variable containing special characters no matter how you escape it. Perhaps the busybox-w32 shell should turn special characters into underscores when it imports the environment. |
|
The latest busybox-32 build replaces invalid characters in shell variable names with underscores. Thus |
|
That will work for all the applets inside busybox - what about when ash et al execute a batch/command script or other win32 application - will it restore the original environment variable name? |
|
No, the original name won't be restored; yes, that's probably a bad thing. So, we could retain the original environment variable but make a copy for the shell with the invalid characters substituted. Then everyone would be happy. |
|
Yes - I think that works - I don't picture the values changing by the user, only to be referenced.... so making a copy with a referable variable name so that the original gets preserved for BB to spawn windows binaries that use those original names will work. |
|
Right, the latest binary preserves |
|
Now works as I would expect - I call it done. |
|
A change to upstream BusyBox about a year ago resulted in variables with invalid names being stripped out. busybox-w32 since FRP-671-ge135a80 was therefore unable to preserve names like This has now been fixed and busybox-w32 from |
|
When executing: |
|
That's correct: That's the tl;dr. Here's the long version: Environment variable names can contain just about any character: the equals sign isn't allowed and using a null character would be unwise but anything else is possible. Shell variables are much more restricted: they can only have alphabetic or numeric characters plus underscore (and they can't start with a digit). When the shell starts it initiialises its variables from the environment. Environment variables with names that are invalid to the shell are excluded. This isn't a problem on Unix because everyone performs self-censorship and only uses environment variable names that are also valid in the shell. Unfortunately nobody told Microsoft that, so they sometimes use names (like To support the use of variables like
This still doesn't allow the shell to change the value of an environment variable with an invalid name. It would be possible to do that too, but it seemed an unnecessary complication. |
|
It seems fine but the problem is that it can be overridden. If I set |
I'm not sure if this is an escaping issue, but I'm unable to check this string in the inherited environment from windows.
I keep getting:
right now the offending line looks like:
The text was updated successfully, but these errors were encountered: