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: Michele Locati
Subject: Re: [bug-gettext] /bin/sh calls in msginit.c on Windows
Date: Tue, 30 Apr 2019 10:52:59 +0200

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;
}

if get_posix_shell() returns NULL we don't make shell calls, otherwise
we use its result as the path to the shell launcher...

--
Michele

Il giorno mar 30 apr 2019 alle ore 09:59 Vincent Torri
<address@hidden> ha scritto:
>
> On Tue, Apr 30, 2019 at 9:52 AM Michele Locati <address@hidden> wrote:
> >
> > In gettext-tools/src/msginit.c there are a few calls to /bin/sh (for
> > example: "/bin/sh /path/to/project-id").
> >
> > What about skipping these calls by enclosing them in a "#if ! defined
> > _WIN32 || defined __CYGWIN__" clause?
> >
> > If so, I can submit a patch.
>
> MSYS2 has bash. Maybe, instead of #ifdef, you can check at runtime if
> /bin/sh exists or not (a system() call should be sufficient).
>
> Vincent
>



reply via email to

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