make-w32
[Top][All Lists]
Advanced

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

Re: How to choose the shell?


From: Eli Zaretskii
Subject: Re: How to choose the shell?
Date: Sun, 05 Sep 2021 22:29:36 +0300

> From: Paul Smith <psmith@gnu.org>
> Cc: jfreeman08@gmail.com, make-w32@gnu.org
> Date: Sun, 05 Sep 2021 15:18:18 -0400
> 
> On Sun, 2021-09-05 at 22:08 +0300, Eli Zaretskii wrote:
> > First, how do you invoke the shell?  On Unix we do "$SHELL -c",
> > right?  What to do on Windows?  Most Windows shells don't support "-
> > c".
> > 
> > Next, what are the characters special to the shell, and how to escape
> > them?  We currently use Unix conventions for that, with some 
> > Windows fixups, but that won't necessarily work with an arbitrary
> > Windows shell.  What to use instead?
> 
> Sorry but I don't follow.  We don't invoke a shell at all: we invoke
> the command in the SHELL variable.

Yes, that's what I meant by $SHELL.

> We don't provide -c at all: we
> provide the options in the .SHELLFLAGS variable.

But there's a default if it is not provided, right?

> We don't escape anything at all: we provide the expansion of the
> command as the first argument.

I was alluding to the code described by this comment in job.c:

    /* SHELL may be a multi-word command.  Construct a command line
       "$(SHELL) $(.SHELLFLAGS) LINE", with all special chars in LINE escaped.
       Then recurse, expanding this command line to get the final
       argument list.  */

> In other words, GNU make should basically run the equivalent of this
> "pidgin code":
> 
>   argv = [$(SHELL)]
>   argv += $(split $(.SHELLFLAGS))
>   argv += ["<command>"]
>   exec(argv);

But that's not exactly what the code there does, according to my
reading of it.

> It's up to the user to make sure the above construct actually works, if
> they're not using a default SHELL.

Before it works, we need to make sure argv[] won't fail the 'exec'
call due to these minor details.

> This is why I raised the generalization of batch files as an issue:
> some commands may not be able to accept "<command>" on the command line
> like that, and if we could provide a _generic_ way to allow makefiles
> to change that final argv value to something else like a reference to a
> batch file where <command> was written, it could help.

Sure, but each shell has its own rules how to write batch files.  We
can support known shells, but what to do with unknown ones?



reply via email to

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