On 5/2/24 3:28 PM, Bruno Haible wrote:
>> Can I apply the attached patched?
> 
> Yes, now it is OK to push.

Done.

>> Also, last night when fixing the quoting issue I was thinking if
>> gnulib-tool.py should quit on unsupported platforms (native Windows).
> 
> Yes, this is reasonable, since we already determined that our
> unsupported platforms are unsupported for a good reason: no adequate
> support for running shell scripts, autoconf, automake.
> 
> However, you need to define "native Windows" here.
>   - A Cygwin (or MSYS2) installation combined with a Cygwin-built Python
>     will work, even without modifications in the subprocess.* calls.
>   - A Cygwin (or MSYS2) installation combined with a native Python
>     will need modifications in the subprocess.* calls, namely to insert a
>     first argument "sh" in many places. (I wouldn't use shell=True in
>     this case, unless we can guarantee that it will call "sh", not "cmd".)
>     Maybe it will also need other modifications, I don't know. Hopefully
>     not.

Ah, good point. I didn't realize it was possible to use a native
Windows Python3 (os.name == 'nt') with Cygwin tools.

What would be the proper way to invoke 'sh' there? For example this
command in GLTestDir.py:

    command = f'patch {shlex.quote(test_driver)} < {shlex.quote(diff)}'
    try:
        result = sp.call(command, shell=True, stdout=sp.DEVNULL, 
stderr=sp.DEVNULL)
    except OSError as exc:
        ...

Would the following be correct?

      command = ['sh', '-c', f'patch {shlex.quote(test_driver)} < 
{shlex.quote(diff)}']
      try:
         result = sp.call(command, stdout=sp.DEVNULL, stderr=sp.DEVNULL)
      except OSError as exc:
         ...

In that case the patch command will be $0 and will be quoted correctly
for when sh is invoked if I am not mistaken.

Collin

Reply via email to