bug-make
[Top][All Lists]

## Re: [bug #41246] Allow to switch shell batch mode at runtime instead of

 From: Eli Zaretskii Subject: Re: [bug #41246] Allow to switch shell batch mode at runtime instead of build time Date: Tue, 04 Feb 2014 18:54:36 +0200

> Date: Tue, 4 Feb 2014 13:34:31 +0900
>
> On Sat, Feb 01, 2014 at 11:29:19AM +0200, Eli Zaretskii wrote:
> > > From: Paul Smith <address@hidden>
> > > Date: Fri, 31 Jan 2014 10:59:13 -0500
> > >
> > > My question, or _challenge_ if you like, is whether we can find a way to
> > > know, without any hints from the user, whether a given command line will
> > > work properly for /bin/sh -c in Windows, or if it needs to use a batch
> > > file.
> >
> > required this?  I'm not sure why would quotes not work with a Unixy
> > shell.
> >
> > Perhaps this is once again something specific to the MSYS conversion
> > of file names?
>
> I'm not sure why it happens, but here's how it manifests:
>
> $cat <<EOF > foo.mk > foo: >$(LS) "c:\\Program Files"
> EOF
> $make -f foo.mk LS=$(which ls)
> C:/mozilla-build/msys/bin/ls.exe "c:\\Program Files"
> C:/mozilla-build/msys/bin/ls.exe: c:\Program: No such file or directory
> C:/mozilla-build/msys/bin/ls.exe: Files: No such file or directory
> foo.mk:2: recipe for target 'foo' failed
> make: *** [foo] Error 2

So you are using the MSYS Bash and MSYS ls.exe from the native build
of Make, right?  Because your recipe succeeds for me both with cmd.exe
and with a native build of a Unixy shell used as a shell by Make.

> This happens for various absolute-path versions of LS, but not when
> LS=ls. This is something I mentioned in bug 40241 comment 12 and 13.
>
> Another issue is with backslashes in paths.
>
> For example:
> \$ cat <<EOF > foo.mk
> foo:
>         grep foo < foo\\bar
> EOF
>
> (Note the < is just there to trigger sh -c)
>
> This executes sh -c "grep foo < foo\\bar", which fails with:
>   /usr/bin/sh: foobar: No such file or directory
> But in batch mode shell, this executes sh makennnnn.sh with a content of
>   grep foo < foo\\bar
> and that fails with:
>   makennnnn.sh: line 1: foo\bar: No such file or directory
>
> (Note how in one case the backslash is eaten and not in the other case)

Why are you using backslashes in file names when your shell is a Unixy
shell?  That makes little sense to me, and I don't see why Make on
Windows should support such use.  Unixy shells are supposed to get
Unixy file names with forward slashes, including in redirection.

> When < is not there and make executes grep directly, it fails with:
>   grep: foo\bar: No such file or directory

Probably because that grep is an MSYS grep, right?

In general, if you are using MSYS shell and commands, you are supposed
to invoke them from the MSYS build of Make.  Otherwise, there can be
no guarantee that commands aimed at native tools will work with MSYS
programs, which are Posix programs with a twist.

I'm willing to support MSYS tools invoked from a native Make, but only
up to a point, and these examples go way beyond that point, sorry.

If I'm confused, and the same problems happen when MSYS is not