Subject: 'wrap-script' introduces spurious argument

From: Ludovic Courtès <[email-masked]>
Date: Thu, 12 Mar 2020 15:26:21 +0100

Hello,

I have a script that starts with:

--8<---------------cut here---------------start------------->8---
#!/gnu/store/29jhbbg1hf557x8j53f9sxd9imlmf02a-bash-minimal-5.0.7/bin/bash
# 
--8<---------------cut here---------------end--------------->8---

When I call ‘wrap-script’ on it, it leads to:

--8<---------------cut here---------------start------------->8---
#!/gnu/store/0awhym5h0m890n0wq87y0dxznh14rk88-guile-next-3.0.1/bin/guile --no-auto-compile
#!#; Guix wrapper
#\-(begin (setenv "PATH" "/gnu/store/9kzrrccpzl6i1sfwb0drb00gi2gwk0x0-coreutils-8.31/bin"))
#\-(let ((cl (command-line))) (apply execl "/gnu/store/29jhbbg1hf557x8j53f9sxd9imlmf02a-bash-minimal-5.0.7/bin/bash" (car cl) (cons (car cl) (append (quote ("")) cl))))
#!/gnu/store/29jhbbg1hf557x8j53f9sxd9imlmf02a-bash-minimal-5.0.7/bin/bash
# 
--8<---------------cut here---------------end--------------->8---

The expression (append '("") cl) is incorrect: the empty string
shouldn’t be added here.

I think one way to fix it is:

diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index b8be73ead4..f9698773c3 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -1295,7 +1295,8 @@ not supported."
                                              (car cl)
                                              (cons (car cl)
                                                    (append
-                                                    ',(string-split args #\space)
+                                                    ',(string-tokenize args
+                                                                       char-set:graphic)
                                                     cl))))))
                    (template (string-append prog ".XXXXXX"))
                    (out      (mkstemp! template))

Ludo’.