-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Issues with env -i #426
Comments
I've found two workarounds for the first problem:
The resulting environment is as empty as it can be and still have batch files work. Details below. How are you determining there's a default The detailsRegarding the first problem: it doesn't require the entire environment to be cleared; it can also be seen with Those two environment variables are special: they're the ones that must have backslashes in their values, or bad things can happen. They're used by Windows when it needs to know how to run They both have to be unset for the problem to arise. If only Trying something else. This works: unset COMSPEC SYSTEMROOT
./mytest.bat Why the difference? What I think is going on: In the case of the shell it's only the shell variables that are unset. The real environment is still present. When the shell comes to run In the case of |
The shell has a The environment created by ~ $ env -i env
BB_GLOBBING=0
~ $
~ $ env -i sh -c env
SHLVL=1
BB_GLOBBING=0
PWD=C:/Users/rmy
~ $
~ $ env -i sh -c 'echo $PATH'
C:/Windows/System32;C:/Windows |
With this I see that there is a default path: Instead with this I see that it isn't exported: PS: I have seen that it is the same on bash online so probably this is correct but still it would be nice to have the batch execution working. Isn't possible to set a default SYSTEMROOT near the code that set the default PATH? |
Sure it's possible, but the question is whether that would be a good thing.
You should know what you're doing when you clean the environment, and part of that knowledge is knowing what you should preserve for your needs. |
Yes, but on Linux it set a default PATH otherwise everything will break (for example mktemp). Put the case that a code is like this: And 2 files: This code would execute the shell file on Linux but break on Windows. PS: Maybe the SYSTEMROOT could be made to be available to batch files but not exported to shell. |
Don't know who's "it", but env and bash and dash don't: $ env -i env # empty output
$ env -i sh -c export # dash
export PWD='/<whatever PWD was originally>'
$ env -i bash -c export
declare -x OLDPWD
declare -x PWD="/<whatever PWD was originally>"
declare -x SHLVL="1" |
They set a default "NOT exported" PATH, try this: |
The issue with I don't think it's practical for busybox-w32 to detect and warn about such problems, much less mitigate them. Consider:
Anything done in |
I'm not sure if I'm doing something wrong but this fail:
env -i ./mytest.bat
The error is:
env: can't execute './mytest.bat': Invalid argument
The content of ./mytest.bat file is just
echo "Abc"
.Also when using env -i a default
PATH
var is reestablished but thisPATH
var is not exported, is it supposed to be like this?The text was updated successfully, but these errors were encountered: