bug-make
[Top][All Lists]
Advanced

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

[PING] [PATCH] Escape space in path to $SHELL


From: Torbjorn SVENSSON
Subject: [PING] [PATCH] Escape space in path to $SHELL
Date: Wed, 12 Jul 2023 17:11:29 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0

Gentle ping...

Kind regards,
Torbjörn

On 2023-07-05 11:09, Torbjörn SVENSSON wrote:
One way to trigger the error is to set SHELL to a path that contain
one space character.

To test the behavior, the following can be used:
        TESTDIR="`mktemp -d '/tmp/make test.XXXXXXXXXX'`" && \
        mkdir -p "$TESTDIR" && \
        cd "$TESTDIR" && \
        ln -s /bin/sh sh && \
        echo -e 'all:\n\t@echo "SHELL is $(SHELL)"' > Makefile && \
        make SHELL="$TESTDIR/sh"

Without the fix:
make: /tmp/make: Command not found
make: *** [Makefile:2: all] Error 127

With the fix:
SHELL is /tmp/make test.o8gS9Mba4b/sh

* src/job.c (construct_command_argv_internal): Escape space in $SHELL
---
  src/job.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/job.c b/src/job.c
index 1c66090c..0bd3f65c 100644
--- a/src/job.c
+++ b/src/job.c
@@ -3390,7 +3390,7 @@ construct_command_argv_internal (char *line, char 
**restp, const char *shell,
         whichever happens first.  */
      for (cp = shell; *cp != '\0'; ++cp)
        {
-        if (strchr (sh_chars, *cp) != 0)
+        if (strchr (sh_chars, *cp) != 0 || ISSPACE(*cp))
            *(ap++) = '\\';
          *(ap++) = *cp;
        }



reply via email to

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