From 03a7b173605a890e1db5177ecd5b8dd591081c41 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 3 May 2019 09:34:55 +0100 Subject: win32: trim leading and trailing spaces from shebang options Commit 97e2c4a05 (win32: changes to treatment of scripts) attempted to use strtok(3) to simplify the parsing of shebang lines. Unfortunately it resulted in leading and trailing whitespace being left in the option string. Fix this by trimming the options before they're returned. Reported-by: Niklas DAHLQUIST Signed-off-by: Ron Yorston --- win32/process.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'win32') diff --git a/win32/process.c b/win32/process.c index 99db6f79f..8546c6e2f 100644 --- a/win32/process.c +++ b/win32/process.c @@ -64,6 +64,10 @@ parse_interpreter(const char *cmd, interp_t *interp) interp->path = path; interp->name = t; interp->opts = strtok(NULL, "\r\n"); + /* Trim leading and trailing whitespace from the options. + * If the resulting string is empty return a NULL pointer. */ + if (interp->opts && trim(interp->opts) == interp->opts) + interp->opts = NULL; return 1; } -- cgit v1.2.3-55-g6feb