unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 92e3774424542c5ce8d7974802de053cd97c5cb9 2421 bytes (raw)
name: gnu/packages/patches/zuo-bin-sh.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
 
From cd6bed5d22ea9cb7bae2be134d5d04433fc8e313 Mon Sep 17 00:00:00 2001
From: Philip McGrath <philip@philipmcgrath.com>
Date: Mon, 11 Apr 2022 20:43:18 -0400
Subject: [PATCH] patch zuo_process for "/bin/sh" on Guix

If:

    1. The nonstandard but ubiquitous macro `_PATH_BSHELL` from
       <paths.h> is defined; and

    2. `zuo_process` is called with the exact path "/bin/sh"; and

    3. The path specified by `_PATH_BSHELL` exists;

then `zuo_process` will execute the file specified by `_PATH_BSHELL`
instead of "/bin/sh".

Checking that the path specified by `_PATH_BSHELL` exists safeguards
against obscure errors if attempting to use the patched Zuo
or derived executables in non-Guix envoronments.
---

Notes:
    See also chez-scheme-bin-sh.patch, racket-chez-scheme-bin-sh.patch,
    racket-rktio-bin-sh.patch.

 zuo.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/zuo.c b/zuo.c
index d4163eb..bfc5484 100644
--- a/zuo.c
+++ b/zuo.c
@@ -16,6 +16,7 @@
 #include <string.h>
 #include <ctype.h>
 #ifdef ZUO_UNIX
+# include <paths.h> /* PATCHED for Guix */
 # include <fcntl.h>
 # include <unistd.h>
 # include <errno.h>
@@ -5949,7 +5950,10 @@ static void zuo_pipe(zuo_raw_handle_t *_r, zuo_raw_handle_t *_w)
 zuo_t *zuo_process(zuo_t *command_and_args)
 {
   const char *who = "process";
-  zuo_t *command = _zuo_car(command_and_args);
+  /* BEGIN PATCH for Guix */
+  zuo_t *_guix_orig_command = _zuo_car(command_and_args);
+  zuo_t *command;
+  /* END PATCH for Guix */
   zuo_t *args = _zuo_cdr(command_and_args), *rev_args = z.o_null;
   zuo_t *options = z.o_empty_hash, *opt;
   zuo_t *dir, *l, *p_handle, *result;
@@ -5960,7 +5964,19 @@ zuo_t *zuo_process(zuo_t *command_and_args)
   void *env;
   int as_child, exact_cmdline;
 
-  check_path_string(who, command);
+  /* BEGIN PATCH for Guix */
+  check_path_string(who, _guix_orig_command);
+#if defined(_PATH_BSHELL)
+  command =
+    ((z.o_false == zuo_string_eql(_guix_orig_command, zuo_string("/bin/sh")))
+     || (z.o_false == zuo_stat(zuo_string(_PATH_BSHELL), z.o_false, z.o_true)))
+    ? _guix_orig_command
+    : zuo_string(_PATH_BSHELL);
+#else
+  command = _guix_orig_command;
+#endif
+  /* END PATCH for Guix */
+
   for (l = args; l->tag == zuo_pair_tag; l = _zuo_cdr(l)) {
     zuo_t *a = _zuo_car(l);
     if (a == z.o_null) {

base-commit: a0faa82c8383d206aa38d21462ca4ae699851a0b
-- 
2.41.0


debug log:

solving 92e3774424 ...
found 92e3774424 in https://git.savannah.gnu.org/cgit/guix.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).