guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: repl macro (metacommand?) for guix CLI (sub)commands


From: Bengt Richter
Subject: Re: repl macro (metacommand?) for guix CLI (sub)commands
Date: Sat, 16 Jul 2022 21:08:31 +0200
User-agent: Mutt/1.10.1 (2018-07-13)

Hi Simon,

On +2022-07-06 14:58:29 +0200, zimoun wrote:
> Hi,
> 
> On mer., 06 juil. 2022 at 14:13, bokr@bokr.com wrote:
> 
> > [13:23 ~/bs]$ guile --no-auto-compile -c '(display (getenv "PS1"))(newline)'
> > [\A \w]\$ 
> 
> On my machine, all is as usual and I run Bash:
> 
> --8<---------------cut here---------------start------------->8---
> $ echo $PS1
> \n\w/\n\u@\h$
> $ guile --no-auto-compile -c '(display (getenv "PS1"))(newline)'
> #f
> --8<---------------cut here---------------end--------------->8---
> 
> Maybe I miss something.   Thanks for giving a try.
> 
> 
> Cheers,
> simon
>

Hm, I see that on my system, I don't get #f from guile like you
--8<---------------cut here---------------start------------->8---
$ echo $PS1
[\A \w]\$
$ guile --no-auto-compile -c '(display (getenv "PS1"))(newline)'
[\A \w]\$ 
--8<---------------cut here---------------end--------------->8---

so I'm not sure what is the difference ;/

Since I was getting PS1 from a bash invocation of guile, I was had
a different impression from yours of reality ;-)

So I went looking for a context where invoking something would NOT see PS1 :)

I found that a nested call of a bash script did not see PS1 unless invoked by 
sourcing.
(Of course I can't source the guile I access with "guile" as a bash command, 
since it's
a binary.) But IIRC guile under guix is actually a wrapper script to set up the 
environment,
so maybe you could on your system -- I've no idea what would happen ;-)


I was thinking that the discussed problem must involve a guile script that
might not be able to sense that it was being invoked by an interactive
repl if it got executed in a nested way as a sub-command,
because the latter would not see a PS1 unless it was in its current environment.

So I was trying to point out that if from the repl you invoke the
nesting script by sourcing it instead of executing it, the sourcing
makes the execution happen in the current environment, and PS1 is seen
and apparently passed on to what the sourced script invokes.

I was lazy about separating stuff, sorry. Comments on the pieces follow:

--8<---------------cut here---------------start------------->8---

What you report above:
┌────────────────────────────────────────────────────────────────────┐
│ > $ echo $PS1                                                      │
│ > \n\w/\n\u@\h$                                                    │
│ > $ guile --no-auto-compile -c '(display (getenv "PS1"))(newline)' │
│ > #f                                                               │
│ >                                                                  │
└────────────────────────────────────────────────────────────────────┘

The guile I'm running:

{ which guile; guile -v; } 
--8<---------------cut here---------------start------------->8---
/usr/bin/guile
guile (GNU Guile) 2.2.4
Packaged by Debian (2.2.4-deb+1-2+deb10u1)
Copyright (C) 2018 Free Software Foundation, Inc.

License LGPLv3+: GNU LGPL 3 or later <http://gnu.org/licenses/lgpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
--8<---------------cut here---------------end--------------->8---

Me: Like you, but not getting #f -- my bug, presumably ? Should this return #f 
for sure?
┌──────────────────────────────────────────────────────────────────────────────┐
│ [13:23 ~/bs]$ guile --no-auto-compile -c '(display (getenv "PS1"))(newline)' │
│ [\A \w]\$                                                                    │
└──────────────────────────────────────────────────────────────────────────────┘
Invoking script[1]  as command, not sourcing -- no PS1 in the command's env 
nested
guile doesn't see it
┌─────────────────────────────────────┐
│ [13:24 ~/bs]$ ./guile-non-int-call  │
│ PS1_val='#f'                        │
│ #f                                  │
└─────────────────────────────────────┘
Sourcing makes the execution happen in the current env, so PS1 is visible
┌────────────────────────────────────────────┐
│ [13:24 ~/bs]$ source ./guile-non-int-call  │
│ PS1_val='[\A \w]\$ '                       │
│ [\A \w]\$                                  │
└────────────────────────────────────────────┘
[1] The script producing the above results as command vs sourced:
┌──────────────────────────────────────────────────────────────────────────────────────┐
│ [13:24 ~/bs]$ cat -nA ./guile-non-int-call                                    
       │
│      1  #!/usr/bin/bash$                                                      
       │
│      2  PS1_val="$(guile --no-auto-compile -c '(display (getenv 
"PS1"))(newline)')"$ │
│      3  echo "PS1_val='$PS1_val'"$                                            
       │
│      4  guile --no-auto-compile -c '(display (getenv "PS1"))(newline)'$       
       │
│ [13:25 ~/bs]$                                                                 
       │
└──────────────────────────────────────────────────────────────────────────────────────┘
--8<---------------cut here---------------end--------------->8---

WDYT?
I need to go back to square 1 default .bash_login and .bashrc to debug this I 
guess :-(
(so .profile and my mods down the .profile sequence will be ignored). Gaah :-/
--
Regards,
Bengt Richter



reply via email to

[Prev in Thread] Current Thread [Next in Thread]