bug-make
[Top][All Lists]
Advanced

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

[PATCH] Escape space in path to $SHELL


From: Torbjörn SVENSSON
Subject: [PATCH] Escape space in path to $SHELL
Date: Wed, 5 Jul 2023 11:09:51 +0200

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




reply via email to

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