guile-user
[Top][All Lists]
Advanced

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

Re: guile 2.0.9 build on mingw


From: Ludovic Courtès
Subject: Re: guile 2.0.9 build on mingw
Date: Sun, 16 Jun 2013 16:36:50 +0200
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

Eli Zaretskii <address@hidden> skribis:

> Here are a few more changes that fix problems exposed by the test
> suite.
>
> The patch below, which should be applied on top of the one I sent
> yesterday, is needed because open-pipe does this:
>
>      (open-pipe* mode "/bin/sh" "-c" command))
>
> and obviously there's no /bin/sh on Windows.
>
> --- libguile/posix.c~1        2013-06-13 08:54:44.926293300 +0300
> +++ libguile/posix.c  2013-06-13 08:57:44.262743700 +0300
> @@ -1300,7 +1300,9 @@ scm_open_process (SCM mode, SCM prog, SC
>    int pid;
>    char *exec_file;
>    char **exec_argv;
> +#ifdef HAVE_FORK
>    int max_fd = 1024;
> +#endif

The #ifdef appears unnecessary given that this is already in #ifdef HAVE_FORK.

>    exec_file = scm_to_locale_string (prog);
>    exec_argv = scm_i_allocate_string_pointers (scm_cons (prog, args));
> @@ -1435,6 +1437,14 @@ scm_open_process (SCM mode, SCM prog, SC
>       close (p2c[0]);
>        }
>  
> +    if (c_strcasecmp (exec_file, "/bin/sh") == 0)
> +      {
> +     strcpy (exec_file, "cmd.exe");
> +     strcpy (exec_argv[0], "cmd.exe");
> +     if (strcmp (exec_argv[1], "-c") == 0)
> +       strcpy (exec_argv[1], "/c");
> +      }
> +
>      pid = spawnvp (P_NOWAIT, exec_file, exec_argv);
>      errno_save = errno;
>  
> @@ -1486,7 +1496,6 @@ scm_open_process (SCM mode, SCM prog, SC
>      {
>        int errno_save = errno;
>  
> -      free (exec_file);
>        if (reading)
>          {
>            close (c2p[0]);
> @@ -1512,6 +1521,7 @@ scm_open_process (SCM mode, SCM prog, SC
>                  exec_file, msg);
>       }
>  #endif
> +      free (exec_file);
>        SCM_SYSERROR;
>      }
>  
> @@ -1592,9 +1602,9 @@ scm_open_process (SCM mode, SCM prog, SC
>      }
>  
>    _exit (EXIT_FAILURE);
> +#endif       /* HAVE_FORK */
>    /* Not reached.  */
>    return SCM_BOOL_F;
> -#endif       /* HAVE_FORK */
>  }
>  #undef FUNC_NAME

This last hunk doesn’t apply since the whole thing is already in
#ifdef HAVE_FORK AFAICS.

What about this (hopefully simpler) patch instead?

diff --git a/module/ice-9/popen.scm b/module/ice-9/popen.scm
index 7d0549e..e431949 100644
--- a/module/ice-9/popen.scm
+++ b/module/ice-9/popen.scm
@@ -61,13 +61,23 @@ port to the process is created: it should be the value of
         (hashq-set! port/pid-table port pid)
         port))))
 
+(define %shell-command
+  (cond ((file-exists? "/bin/sh")
+         "/bin/sh")
+        ((getenv "SHELL")
+         ;; Hope that $SHELL points at a Bourne-compatible shell.
+         => identity)
+        (else
+         ;; Assume we're on Windows.
+         "cmd.exe")))
+
 (define (open-pipe command mode)
   "Executes the shell command @var{command} (a string) in a subprocess.
 A port to the process (based on pipes) is created and returned.
 @var{mode} specifies whether an input, an output or an input-output
 port to the process is created: it should be the value of
 @code{OPEN_READ}, @code{OPEN_WRITE} or @code{OPEN_BOTH}."
-  (open-pipe* mode "/bin/sh" "-c" command))
+  (open-pipe* mode %shell-command "-c" command))
 
 (define (fetch-pid port)
   (let ((pid (hashq-ref port/pid-table port)))
Thanks,
Ludo’.

reply via email to

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