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
Unix.open_process_full has trouble with UTF-8 environment variables on Linux #7561
Comments
Comment author: @nojb I uploaded test.ml since Mantis messed up the non-ASCII characters. |
Comment author: @nojb This morning in an Arch Linux box (I tried it in a Ubuntu VM yesterday) I cannot reproduce the problem. |
Comment author: @nojb However, it is still there in my Ubuntu 16.04 (Xenial) VM. It would be useful if someone could try it out in a non-VM setting. |
Comment author: @nojb It seems the problem is when the "keys" (to the left of the equal sign) are not ASCII. |
Comment author: @nojb Aha! mystery solved. There are some shells (e.g. dash, but not bash) which do not allow any non ASCII character in variable names. Unix.open_process_full uses /bin/sh to run the command. In Ubuntu, /bin/sh is a symlink to dash, hence the observed behaviour. Under OS X (and I bet Arch, but can't check now), /bin/sh is an alias to /bin/bash so no problem there. So, not a bug after all! |
Comment author: @xavierleroy Thanks for the detective work! Marking this as "resolved" because it's not an OCaml issue. |
Original bug ID: 7561
Reporter: @nojb
Status: resolved (set by @xavierleroy on 2017-06-22T18:06:23Z)
Resolution: not a bug
Priority: normal
Severity: minor
Category: otherlibs
Monitored by: @dbuenzli
Bug description
I found the following puzzling behaviour while working on #1200.
Unix.open_process_full seems to have problems with with UTF-8 characters in the "env" parameter. See steps to reproduce below.
When passing ASCII characters it works fine.
Using the Unix.execve call (rather than Unix.open_process_full) seems to work fine.
It also works fine on Windows (where a different implementation is used).
I tried it with trunk and 4.05.
Steps to reproduce
Put the following in printenv.c:
and in test.ml:
Compile & run by doing
In my machine I see only the second line of envp and PWD as output.
File attachments
The text was updated successfully, but these errors were encountered: