Subject: Re: bug#44612: Read standard input in `guix repl'

From: Guillaume Le Vaillant <[email-masked]>
Date: Sat, 14 Nov 2020 16:03:56 +0100

Tobias Geerinckx-Rice via Bug reports for GNU Guix <[email-masked]> skribis:

> Pierre,
>
> Pierre Neidhardt 写道：
>> and... it works! O.o
>
> Don't you hate it when that happens?  Ban bug suicide.
>
> (Does that mean this one can be closed?  Or retitled, if we want to debug
> Nyxt? :-)
>
>> For future reference, it's also works in Common Lisp:
>>            (uiop:run-program '("guix" "repl") :input s :output
>> t            :error-output nil))
>
> Well, I stranded trying to import (or whatever the CL term is) UIOP itself, but
> my Common Lisp-fu is hella weak.
>
>> However this brings me to another issue: the program output is prefixed
>> with the REPL welcome message which is printed to stdout.
>>
>> So ideally when we read from standard input we should not include the
>> welcome message.
>
> That's a question for Guile channels, but I totally agree.  It's annoying and
> nowhere near ‘an interactive mode’ as suggested by the GPL3.
>
> This is sensible:
>
>  $ echo echo Hi. | bash
>  Hi.
>  $ 
> This is not:
>
>  $ echo '(display "Hi.\n")' | guile
>  GNU Guile 3.0.2
>  Copyright (C) 1995-2020 Free Software Foundation, Inc.
>
>  Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show   w'.
>  This program is free software, and you are welcome to   redistribute it
>  under certain conditions; type `,show c' for details.
>
>  Enter `,help' for help.
>  Hi.
>  scheme@(guile-user)>   $
>
>> Any clue how to do that?
>
> The following line in my ~/.guile does just that:
>
>  (set! repl-welcome (const #t))
>
> ...unfortunately, it doesn't work late:
>
>  $ echo '(use-modules ((system repl common))) \
>    (set! repl-welcome (const #t))' | guix repl
>  [shouty noises]
>  $
>
> It does not appear documented if and how you'd make Guile load a different
> (Nyxt-specific) init file name.
>
> This reminds me: do you want Nyxt to call ‘guix repl -q’ to skip loading
> ~/.guile to make your UI more predictable & debuggable? Or keep it as an escape
> hatch for cool hacks?
>
> Kind regards,
>
> T G-R

It looks like you can get rid of the welcome message by using the '-s'
option:

$ echo '(display "Hi.\n")' | guile -s /dev/stdin
Hi.