unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob ad42616c702494fd0ac72078ae09b51af6c36393 1690 bytes (raw)
name: gnu/packages/patches/guile-bash-args-from-stdin.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
 
From a124921666a16cb4e93f59a653f98b99c78eb2ca Mon Sep 17 00:00:00 2001
From: David Larsson <david.larsson@selfhosted.xyz>
Date: Thu, 11 Nov 2021 14:07:04 +0100
Subject: [PATCH] Enable reading arguments from bash via stdin

* lisp/gnu/bash.scm(define-bash-function): read from stdin
to SCM_ARGS array when it is open, and separate args by null
instead of newline if -z option is passed as $1.
---
 lisp/gnu/bash.scm | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lisp/gnu/bash.scm b/lisp/gnu/bash.scm
index 199ebc0..e9dcea5 100644
--- a/lisp/gnu/bash.scm
+++ b/lisp/gnu/bash.scm
@@ -326,10 +326,18 @@
       (hashq-set! *funcs* symbol thunk)
       (unsafe-format/eval
        "function ~a {
-            SCM_ARGS=($@)    ;
-            local retval=$~a ;
-            unset SCM_ARGS   ;
-            return $retval   ;
+            local -a Input SCM_ARGS                                          ;
+            [[ ! -t 0 ]] && mapfile -d '' Input                              ;
+            if [[ -n \"${Input[@]}\" ]]; then
+                if [[ \"$1\" == -z ]]; then
+                    local -a SCM_ARGS=\"(${Input[*]@Q})\"                    ;
+                else
+                    mapfile -t SCM_ARGS < <(printf '%s' \"${Input[@]}\"); fi ;
+            else
+                SCM_ARGS=(\"$@\"); fi                                        ;
+            local retval=$~a                                                 ;
+            unset SCM_ARGS                                                   ;
+            return $retval                                                   ;
        }"
        symbol special-varname))))
 
-- 
2.31.0


debug log:

solving ad42616c70 ...
found ad42616c70 in https://yhetil.org/guix-patches/b9336e4ef177af5e3b4c02b40012d01a@selfhosted.xyz/ ||
	https://yhetil.org/guix-patches/8d6b871864d52beebcdbe83cae97769c@selfhosted.xyz/ ||
	https://yhetil.org/guix-patches/bbb463a262deb7d59525297e337c6253@selfhosted.xyz/ ||
	https://yhetil.org/guix-patches/650e73fe887c2524947b7c06d9dc9994@selfhosted.xyz/ ||
	https://yhetil.org/guix-patches/916da2bcc898e4a8d87747729dff9eb0@selfhosted.xyz/ ||
	https://yhetil.org/guix-patches/71292d0dac4dbd1bb84be950dca2e9c4@selfhosted.xyz/ ||
	https://yhetil.org/guix-patches/ea47033291a9529bdbd6b616d334f79d@selfhosted.xyz/ ||
	https://yhetil.org/guix-patches/fbcca6e0e0c80f5b90cb44ce6066268f@selfhosted.xyz/ ||
	https://yhetil.org/guix-patches/482320c017a2ab923b040cb83746e563@selfhosted.xyz/

applying [1/1] https://yhetil.org/guix-patches/b9336e4ef177af5e3b4c02b40012d01a@selfhosted.xyz/
index 0000000000..ad42616c70

1:29: trailing whitespace.
+            local -a Input SCM_ARGS                                    
1:31: trailing whitespace.
+            [[ ! -t 0 ]] && mapfile -d '' Input                        
1:35: trailing whitespace.
+                    local -a SCM_ARGS=\"(${Input[*]@Q})\"              
1:38: trailing whitespace.
+                    mapfile -t SCM_ARGS < <(printf '%s' 
error: corrupt patch at line 39

git apply error:; exit status=128
trying https://yhetil.org/guix-patches/b9336e4ef177af5e3b4c02b40012d01a@selfhosted.xyz/

applying [2/1] https://yhetil.org/guix-patches/b9336e4ef177af5e3b4c02b40012d01a@selfhosted.xyz/
diff --git a/gnu/packages/patches/guile-bash-args-from-stdin.patch b/gnu/packages/patches/guile-bash-args-from-stdin.patch
new file mode 100644
index 0000000000..ad42616c70

2:45: trailing whitespace.
 
2:46: trailing whitespace.
-- 
Checking patch gnu/packages/patches/guile-bash-args-from-stdin.patch...
2:48: new blank line at EOF.
+
Applied patch gnu/packages/patches/guile-bash-args-from-stdin.patch cleanly.
warning: 3 lines add whitespace errors.

skipping https://yhetil.org/guix-patches/8d6b871864d52beebcdbe83cae97769c@selfhosted.xyz/ for ad42616c70
skipping https://yhetil.org/guix-patches/bbb463a262deb7d59525297e337c6253@selfhosted.xyz/ for ad42616c70
skipping https://yhetil.org/guix-patches/650e73fe887c2524947b7c06d9dc9994@selfhosted.xyz/ for ad42616c70
skipping https://yhetil.org/guix-patches/916da2bcc898e4a8d87747729dff9eb0@selfhosted.xyz/ for ad42616c70
skipping https://yhetil.org/guix-patches/71292d0dac4dbd1bb84be950dca2e9c4@selfhosted.xyz/ for ad42616c70
skipping https://yhetil.org/guix-patches/ea47033291a9529bdbd6b616d334f79d@selfhosted.xyz/ for ad42616c70
skipping https://yhetil.org/guix-patches/fbcca6e0e0c80f5b90cb44ce6066268f@selfhosted.xyz/ for ad42616c70
skipping https://yhetil.org/guix-patches/482320c017a2ab923b040cb83746e563@selfhosted.xyz/ for ad42616c70
index at:
100644 ad42616c702494fd0ac72078ae09b51af6c36393	gnu/packages/patches/guile-bash-args-from-stdin.patch

(*) 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).