Re: bash scripts in Guix question
On Wed, 05 Oct 2022, Maxim Cournoyer wrote: > Hi, > > Olivier Dion writes: > > [...] > >>> I prefer the "#!/usr/bin/env bash" shebang; /usr/bin/env is available on >>> FHS distribution, and on Guix System, for convenience. You can use if >>> for any interpreted script, such as Guile, Python, Perl, etc. >> >> Only if coreutils is in the profile that would work yes. > > coreutils doesn't need to be in the profile since /usr/bin/env is linked > to (file-append coreutils "bin/env"); see in the value of %base-services > in (gnu services base), which contains: > > --8<---cut here---start->8--- > (service special-files-service-type > `(("/bin/sh" ,(file-append bash "/bin/sh")) >("/usr/bin/env" ,(file-append coreutils "/bin/env" > --8<---cut here---end--->8--- Oh interesting I did not know that. Thank you! -- Olivier Dion oldiob.dev
Re: bash scripts in Guix question
Hi, Olivier Dion writes: [...] >> I prefer the "#!/usr/bin/env bash" shebang; /usr/bin/env is available on >> FHS distribution, and on Guix System, for convenience. You can use if >> for any interpreted script, such as Guile, Python, Perl, etc. > > Only if coreutils is in the profile that would work yes. coreutils doesn't need to be in the profile since /usr/bin/env is linked to (file-append coreutils "bin/env"); see in the value of %base-services in (gnu services base), which contains: --8<---cut here---start->8--- (service special-files-service-type `(("/bin/sh" ,(file-append bash "/bin/sh")) ("/usr/bin/env" ,(file-append coreutils "/bin/env" --8<---cut here---end--->8--- 'env' looks up the command passed to it from PATH, but that's usually satisfied if you were going to use a FHS location anyway such as "/bin/bash". -- Thanks, Maxim
Re: bash scripts in Guix question - suspend ?
Hi jordi, >I'm puzzled, as long as 'loginctl suspend' is working in the shell But '~/.config/i3/i3exit loginctl suspend' isn't. Judging by your original snippet, you've mashed two commands together: you meant either ~/.config/i3/i3exit suspend or loginctl suspend But nobody here can tell you for certain how to call your 'i3exit' script without knowing what's in it. Aside: you seem to be writing a wrapper script to wrap a wrapper script to call a wrapper for writing to /proc. Is that necessary? It can make things hard to follow. Kind regards, T G-R Sent on the go. Excuse or enjoy my brevity.
Re: bash scripts in Guix question
On Tue, 04 Oct 2022, Maxim Cournoyer wrote: > Hi, > > Olivier Dion via writes: > >> On Tue, 04 Oct 2022, jordi wrote: >>> Hi guixers, >>> >>> i'm wondering...for my scripts to work in Guix, instead of >>> '#!/bin/bash' , >>> >> >> Typically the `sh' program should be a symlinked to `bash' in your >> system profile. I think it is the case for many distro. If you want it >> to be bulletproof though for other distros maybe something like that: >> >> #!/bin/sh >> if [ "$(basename $SHELL)" != "bash" ]; then >> exec bash "$0" "$@" >> fi >> >> echo "hey!" > > I prefer the "#!/usr/bin/env bash" shebang; /usr/bin/env is available on > FHS distribution, and on Guix System, for convenience. You can use if > for any interpreted script, such as Guile, Python, Perl, etc. Only if coreutils is in the profile that would work yes. -- Olivier Dion oldiob.dev
Re: bash scripts in Guix question
Hi, Olivier Dion via writes: > On Tue, 04 Oct 2022, jordi wrote: >> Hi guixers, >> >> i'm wondering...for my scripts to work in Guix, instead of >> '#! /bin/bash' , >> > > Typically the `sh' program should be a symlinked to `bash' in your > system profile. I think it is the case for many distro. If you want it > to be bulletproof though for other distros maybe something like that: > > #!/bin/sh > if [ "$(basename $SHELL)" != "bash" ]; then > exec bash "$0" "$@" > fi > > echo "hey!" I prefer the "#!/usr/bin/env bash" shebang; /usr/bin/env is available on FHS distribution, and on Guix System, for convenience. You can use if for any interpreted script, such as Guile, Python, Perl, etc. -- Thanks, Maxim
Re: bash scripts in Guix question
Le Tue, Oct 04, 2022 at 03:18:36PM +0200, jordi a écrit : > Hi guixers, Hello! > > i'm wondering...for my scripts to work in Guix, instead of > '#! /bin/bash' , > > what do i have to start them with ? #!/usr/bin/env bash And if you need to pass arguments/options, take a look at $ info '(coreutils) env invocation' > Thanks,thanks, thanks Welcome!
Re: bash scripts in Guix question
On Tue, 04 Oct 2022, jordi wrote: > Hi guixers, > > i'm wondering...for my scripts to work in Guix, instead of > '#! /bin/bash' , > Typically the `sh' program should be a symlinked to `bash' in your system profile. I think it is the case for many distro. If you want it to be bulletproof though for other distros maybe something like that: --8<---cut here---start->8--- #!/bin/sh if [ "$(basename $SHELL)" != "bash" ]; then exec bash "$0" "$@" fi echo "hey!" --8<---cut here---end--->8--- -- Olivier Dion oldiob.dev
Re: bash scripts in Guix question
Hi, > Hi guixers, > > i'm wondering...for my scripts to work in Guix, instead of > '#! /bin/bash' , > > what do i have to start them with ? > > Thanks,thanks, thanks > > F We have a link to bash located in /bin/sh so you can just leave /bin/sh. Or you can also use `#!/usr/bin/env bash` Both should work. Cheers, Ekaitz
bash scripts in Guix question
Hi guixers, i'm wondering...for my scripts to work in Guix, instead of '#!/bin/bash' , what do i have to start them with ? Thanks,thanks, thanks F