diff mbox series

[hurd,commited] hurd: Fix spawni SPAWN_XFLAGS_TRY_SHELL with empty argv

Message ID 20201226154051.30042-1-samuel.thibault@ens-lyon.org
State New
Headers show
Series [hurd,commited] hurd: Fix spawni SPAWN_XFLAGS_TRY_SHELL with empty argv | expand

Commit Message

Samuel Thibault Dec. 26, 2020, 3:40 p.m. UTC
When argv is empty, we need to add the original script to be run on the
shell command line.
---
 sysdeps/mach/hurd/spawni.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c
index 2aeed683fe..b511265044 100644
--- a/sysdeps/mach/hurd/spawni.c
+++ b/sysdeps/mach/hurd/spawni.c
@@ -842,7 +842,11 @@  __spawni (pid_t *pid, const char *file,
       {
 	/* The file is accessible but it is not an executable file.
 	   Invoke the shell to interpret it as a script.  */
-	err = __argz_insert (&args, &argslen, args, _PATH_BSHELL);
+	err = 0;
+	if (!argslen)
+	  err = __argz_insert (&args, &argslen, args, relpath);
+	if (!err)
+	  err = __argz_insert (&args, &argslen, args, _PATH_BSHELL);
 	if (!err)
 	  err = child_lookup (_PATH_BSHELL, O_EXEC, 0, &execfile);
 	if (!err)