bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gettext] /bin/sh calls in msginit.c on Windows


From: Bruno Haible
Subject: Re: [bug-gettext] /bin/sh calls in msginit.c on Windows
Date: Sat, 04 May 2019 15:21:34 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-145-generic; KDE/5.18.0; x86_64; ; )

Hi Michele and Vincent,

> What about skipping these calls by enclosing them in a "#if ! defined
> _WIN32 || defined __CYGWIN__" clause?

This would be possible. But it is not needed, as all uses (in the functions
project_id, project_id_version, get_user_email, language_team_address) have
a fallback ('goto failed;') that will make the lack of /bin/sh harmless.

> MSYS2 has bash. Maybe, instead of #ifdef, you can check at runtime if
> /bin/sh exists or not (a system() call should be sufficient).

The calls to create_pipe_in (prog, "/bin/sh", ...) do exactly this:
they perform a runtime check.

> Well, this makes me think that Windows can now run POSIX commands, if
> users enabled Windows Subsystem for Linux.
> 
> So, what about adding a function like this?
> 
> #include <stdlib.h>
> #include <unistd.h>
> 
> static const char *
> get_posix_shell ()
> {
>   if (access("/bin/sh", X_OK) == 0)
>     {
>       return "/bin/sh";
>     }
> 
> #if defined _WIN32
>   if (system("where wsl.exe >NUL 2>&1"))
>     {
>       return "wsl.exe";
>     }
> #endif
> 
>   return NULL;
> }

I wouldn't want to use wsl.exe from a mingw program.
1. Microsoft documents that accessing the same files from the Linux side
   and from the Windows side can lead to file system corruption. [1]
2. The user experience is likely unexpected and unsatisfying, because
   wsl.exe is really a different world than the rest of Windows.

Bruno

[1] 
https://devblogs.microsoft.com/commandline/whats-new-for-wsl-in-windows-10-version-1903/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]