mbox series

[bug#51791,0/2] : Update guile-bash

Message ID cb85c24cfbbe08819ec2ce5381259059@selfhosted.xyz
Headers show
Series : Update guile-bash | expand

Message

david larsson Nov. 12, 2021, 1:56 p.m. UTC
Hi,

The following 2 patches update the guile-bash source url and home-page, 
and adds a patch for it that does 2 things:
   - fixes a bug, see below
   - enables reading newline- or null-separated arguments via stdin to 
guile-bash-defined bash functions.

The bug is that guile-bash can't read string args with whitespaces in 
it. Example:
------------------------
~$ enable -f ~/.guix-profile/lib/bash/libguile-bash.so scm
~$ scm /tmp/printargs
~$ printargs "apa bepa" cepa
In procedure printargs: scm-function called from Bash with args (apa 
bepa cepa) failed to match signature (file1 file2)
~$ cat /tmp/printargs
(use-modules
  (gnu bash))
(define-bash-function (printargs file1 file2)
     (display file1)
     (display "\n")
     (display file2)
     (display "\n"))
-------------------------

After this patch, you can read args "as normal", or via stdin that are 
either newline- or null-separated:
-------------------------
~$ printargs "apa bepa" cepa
apa bepa
cepa
~$ echo "$apa"
aba
aca
~$ printf '%s\0' "$apa" bepa | printargs -z
aba
aca
bepa
~$ echo "$apa" | printargs
aba
aca
-------------------------

Best regards,
David

Comments

Ricardo Wurmus Dec. 1, 2021, 7:20 a.m. UTC | #1
Hi David,

thank you for the update!  What is the upstream status of this 
patch?  Has it been sent to upstream?  Is upstream development 
continuing?  (That’s what the new home-page implies.)
david larsson Dec. 1, 2021, 10:28 a.m. UTC | #2
On 2021-12-01 08:20, Ricardo Wurmus wrote:
> Hi David,
> 
> thank you for the update!  What is the upstream status of this patch?
> Has it been sent to upstream?  Is upstream development continuing?
> (That’s what the new home-page implies.)

I have sent a patch a couple weeks ago via sr.ht (my fork is here: 
https://git.sr.ht/~methuselah-0/guile-bash) to the author but no 
response so far.

The latest patch is from 6 years ago so development has probably not 
restarted.

I still think it would be good to change the upstream to sr.ht because 
it very much looks like it's the original author's repository (username 
is kaction) and it has all the change history - versus as it is now 
where I think software heritage is used when building it from source (or 
maybe a cached version on the build farms).

Best regards,
David
david larsson Dec. 15, 2021, 11:54 a.m. UTC | #3
If anyone wants to install a guile-bash that can read arguments with 
whitespace, and newlines, you can install it like this:

wget -O /tmp/patch.temp http://paste.debian.net/plain/1223545 ; guix 
package --with-patch=guile-bash=/tmp/patch.temp -i guile-bash


Then prepare it like this for example:

------------------------------------------
$ export GUILE_AUTO_COMPILE=0
$ enable -f ~/.guix-profile/lib/bash/libguile-bash.so scm
$ cat <<'EOF'>/tmp/printargs.scm
(use-modules
  (gnu bash))
(define-bash-function (printargs file1 file2)
     (display file1)
     (display "\n")
     (display file2)
     (display "\n"))
EOF
$ scm /tmp/printargs.scm
-------------------------

And then use the guile function from bash like this:

-------------------------
~$ printargs "apa bepa" cepa
apa bepa
cepa
~$ echo "$apa"
aba
aca
~$ printf '%s\0' "$apa" bepa | printargs -z
aba
aca
bepa
~$ echo "$apa" | printargs
aba
aca
-------------------------


Closing this bug now.
david larsson Dec. 15, 2021, 11:55 a.m. UTC | #4
done