]> Savannah Git Hosting - gnulib.git/commitdiff
sh-filename: New module.
authorBruno Haible <bruno@clisp.org>
Thu, 4 Oct 2018 23:38:46 +0000 (01:38 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 4 Oct 2018 23:38:46 +0000 (01:38 +0200)
* m4/sh-filename.m4: New file.
* modules/sh-filename: New file.
* lib/spawni.c (_PATH_BSHELL): Use BOURNE_SHELL instead of hardcoding
"/bin/sh".
* tests/test-posix_spawn1.c (main): Likewise.
* tests/test-posix_spawn2.c (main): Likewise.
* lib/javacomp.c (compile_using_envjavac, is_envjavac_gcj,
is_envjavac_gcj43): Likewise.
* lib/javaexec.c (execute_java_class): Likewise.
* modules/posix_spawn-internal (Depends-on): Add sh-filename.
* modules/posix_spawnp-tests (Depends-on): Likewise.
* modules/javacomp (Depends-on): Likewise.
* modules/javaexec (Depends-on): Likewise.

12 files changed:
ChangeLog
lib/javacomp.c
lib/javaexec.c
lib/spawni.c
m4/sh-filename.m4 [new file with mode: 0644]
modules/javacomp
modules/javaexec
modules/posix_spawn-internal
modules/posix_spawnp-tests
modules/sh-filename [new file with mode: 0644]
tests/test-posix_spawn1.c
tests/test-posix_spawn2.c

index 23a27685df83aa008e07899c50d9dc78ec8e1c5d..d860386441277ad4a154165f165da485e4f80e1a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2018-10-04  Bruno Haible  <bruno@clisp.org>
+
+       sh-filename: New module.
+       * m4/sh-filename.m4: New file.
+       * modules/sh-filename: New file.
+       * lib/spawni.c (_PATH_BSHELL): Use BOURNE_SHELL instead of hardcoding
+       "/bin/sh".
+       * tests/test-posix_spawn1.c (main): Likewise.
+       * tests/test-posix_spawn2.c (main): Likewise.
+       * lib/javacomp.c (compile_using_envjavac, is_envjavac_gcj,
+       is_envjavac_gcj43): Likewise.
+       * lib/javaexec.c (execute_java_class): Likewise.
+       * modules/posix_spawn-internal (Depends-on): Add sh-filename.
+       * modules/posix_spawnp-tests (Depends-on): Likewise.
+       * modules/javacomp (Depends-on): Likewise.
+       * modules/javaexec (Depends-on): Likewise.
+
 2018-10-04  Bruno Haible  <bruno@clisp.org>
 
        spawn-pipe tests: Avoid test failure on native Windows.
index 9d5b24907028d29600c82ef7c03493965df63b77..779d5ec2ecd6611d83ab6e2b57967577be663dd8 100644 (file)
@@ -339,11 +339,11 @@ compile_using_envjavac (const char *javac,
   if (verbose)
     printf ("%s\n", command);
 
-  argv[0] = "/bin/sh";
+  argv[0] = BOURNE_SHELL;
   argv[1] = "-c";
   argv[2] = command;
   argv[3] = NULL;
-  exitstatus = execute (javac, "/bin/sh", argv, false, false, false,
+  exitstatus = execute (javac, BOURNE_SHELL, argv, false, false, false,
                         null_stderr, true, true, NULL);
   err = (exitstatus != 0);
 
@@ -656,11 +656,11 @@ is_envjavac_gcj (const char *javac)
         abort ();
 
       /* Call $JAVAC --version 2>/dev/null.  */
-      argv[0] = "/bin/sh";
+      argv[0] = BOURNE_SHELL;
       argv[1] = "-c";
       argv[2] = command;
       argv[3] = NULL;
-      child = create_pipe_in (javac, "/bin/sh", argv, DEV_NULL, true, true,
+      child = create_pipe_in (javac, BOURNE_SHELL, argv, DEV_NULL, true, true,
                               false, fd);
       if (child == -1)
         goto failed;
@@ -738,11 +738,11 @@ is_envjavac_gcj43 (const char *javac)
         abort ();
 
       /* Call $JAVAC --version 2>/dev/null.  */
-      argv[0] = "/bin/sh";
+      argv[0] = BOURNE_SHELL;
       argv[1] = "-c";
       argv[2] = command;
       argv[3] = NULL;
-      child = create_pipe_in (javac, "/bin/sh", argv, DEV_NULL, true, true,
+      child = create_pipe_in (javac, BOURNE_SHELL, argv, DEV_NULL, true, true,
                               false, fd);
       if (child == -1)
         goto failed;
index b6f2eff0e82b893c6b4e9f40f39c6ba86137d61a..2dd68537993ad7a342f6806ef1647ba7944ca299 100644 (file)
@@ -172,11 +172,11 @@ execute_java_class (const char *class_name,
         if (verbose)
           printf ("%s\n", command);
 
-        argv[0] = "/bin/sh";
+        argv[0] = BOURNE_SHELL;
         argv[1] = "-c";
         argv[2] = command;
         argv[3] = NULL;
-        err = executer (java, "/bin/sh", argv, private_data);
+        err = executer (java, BOURNE_SHELL, argv, private_data);
 
         freea (command);
 
index bd49cc88ad5e5d185801c9f37731d76090621704..05dc8b46e5167a5e4029e81c18bab8a06d673932 100644 (file)
@@ -32,7 +32,7 @@
 #if _LIBC || HAVE_PATHS_H
 # include <paths.h>
 #else
-# define _PATH_BSHELL "/bin/sh"
+# define _PATH_BSHELL BOURNE_SHELL
 #endif
 
 #include <signal.h>
diff --git a/m4/sh-filename.m4 b/m4/sh-filename.m4
new file mode 100644 (file)
index 0000000..53148f4
--- /dev/null
@@ -0,0 +1,20 @@
+# sh-filename.m4 serial 1
+dnl Copyright (C) 2018 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([gl_SH_FILENAME],
+[
+  AH_VERBATIM([SH_FILENAME],
+[/* File name of the Bourne shell.  */
+#if defined __CYGWIN__
+/* Omit the directory part because for 32-bit Cygwin programs in a
+   64-bit Cygwin environment, the Cygwin mounts are not visible.  */
+# define BOURNE_SHELL "sh"
+#else
+# define BOURNE_SHELL "/bin/sh"
+#endif])
+])
index dcfcae8e0490145ec10973b66a5664b9551543f6..2568a9e54c42a4ceb4c49923c20db6d161951c60 100644 (file)
@@ -28,6 +28,7 @@ xvasprintf
 c-strstr
 gettext-h
 javacomp-script
+sh-filename
 
 configure.ac:
 
index b66c2fc81e01e79f9501920b3dade7059d130ba5..879580a12d42ef930fab1bab09f9f38753b0b878 100644 (file)
@@ -17,6 +17,7 @@ xmalloca
 error
 gettext-h
 javaexec-script
+sh-filename
 
 configure.ac:
 
index b1ab488409b7c6377ca608744673f630f7ea9be4..294b3f83c9afdf0ca0d2afa6e3715db98c50196f 100644 (file)
@@ -12,6 +12,7 @@ alloca-opt
 dup2
 errno
 open
+sh-filename
 strchrnul
 
 configure.ac:
index bce8be77772b34f50632a68184eaa86be03932a0..743c95f0ee69d828a0e2a7839b812013e91a9c30 100644 (file)
@@ -20,6 +20,7 @@ unistd
 sys_wait
 dup
 environ
+sh-filename
 sigprocmask
 
 configure.ac:
diff --git a/modules/sh-filename b/modules/sh-filename
new file mode 100644 (file)
index 0000000..7043fc1
--- /dev/null
@@ -0,0 +1,20 @@
+Description:
+Provide BOURNE_SHELL, the file name of the standard Bourne shell.
+
+Files:
+m4/sh-filename.m4
+
+Depends-on:
+
+configure.ac:
+gl_SH_FILENAME
+
+Makefile.am:
+
+Include:
+
+License:
+LGPLv2+
+
+Maintainer:
+all
index 6b6c864f4d8cc6333f3007ac2c4f1eb8d1882db5..c6b59ddd6dc95ceaf52b36e7f42ea8e339038bb1 100644 (file)
@@ -73,7 +73,7 @@ fd_safer (int fd)
 int
 main ()
 {
-  char *argv[3] = { (char *) "/bin/sh", (char *) CHILD_PROGRAM_FILENAME, NULL };
+  char *argv[3] = { (char *) BOURNE_SHELL, (char *) CHILD_PROGRAM_FILENAME, NULL };
   int ifd[2];
   sigset_t blocked_signals;
   sigset_t fatal_signal_set;
@@ -113,7 +113,7 @@ main ()
           || (attrs_allocated = true,
               (err = posix_spawnattr_setsigmask (&attrs, &blocked_signals)) != 0
               || (err = posix_spawnattr_setflags (&attrs, POSIX_SPAWN_SETSIGMASK)) != 0)
-          || (err = posix_spawnp (&child, "/bin/sh", &actions, &attrs, argv, environ)) != 0))
+          || (err = posix_spawnp (&child, BOURNE_SHELL, &actions, &attrs, argv, environ)) != 0))
     {
       if (actions_allocated)
         posix_spawn_file_actions_destroy (&actions);
index d9f29a111585c8cf4809f92cb9b964e60bae1497..1311951d3cb8749b1af45acd0b41bf5e98746bca 100644 (file)
@@ -51,7 +51,7 @@ fd_safer (int fd)
 int
 main ()
 {
-  char *argv[3] = { (char *) "/bin/sh", (char *) CHILD_PROGRAM_FILENAME, NULL };
+  char *argv[3] = { (char *) BOURNE_SHELL, (char *) CHILD_PROGRAM_FILENAME, NULL };
   int ofd[2];
   sigset_t blocked_signals;
   sigset_t fatal_signal_set;
@@ -90,7 +90,7 @@ main ()
           || (attrs_allocated = true,
               (err = posix_spawnattr_setsigmask (&attrs, &blocked_signals)) != 0
               || (err = posix_spawnattr_setflags (&attrs, POSIX_SPAWN_SETSIGMASK)) != 0)
-          || (err = posix_spawnp (&child, "/bin/sh", &actions, &attrs, argv, environ)) != 0))
+          || (err = posix_spawnp (&child, BOURNE_SHELL, &actions, &attrs, argv, environ)) != 0))
     {
       if (actions_allocated)
         posix_spawn_file_actions_destroy (&actions);