unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* bash scripts in Guix question
@ 2022-10-04 13:18 jordi
  2022-10-04 14:10 ` Ekaitz Zarraga
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: jordi @ 2022-10-04 13:18 UTC (permalink / raw)
  To: help-guix

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: bash scripts in Guix question
  2022-10-04 13:18 bash scripts in Guix question jordi
@ 2022-10-04 14:10 ` Ekaitz Zarraga
  2022-10-04 14:31 ` Fulbert
  2022-10-04 14:38 ` Olivier Dion via
  2 siblings, 0 replies; 10+ messages in thread
From: Ekaitz Zarraga @ 2022-10-04 14:10 UTC (permalink / raw)
  To: jordi; +Cc: help-guix

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: bash scripts in Guix question
  2022-10-04 13:18 bash scripts in Guix question jordi
  2022-10-04 14:10 ` Ekaitz Zarraga
@ 2022-10-04 14:31 ` Fulbert
  2022-10-04 14:38 ` Olivier Dion via
  2 siblings, 0 replies; 10+ messages in thread
From: Fulbert @ 2022-10-04 14:31 UTC (permalink / raw)
  To: help-guix

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!


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: bash scripts in Guix question
  2022-10-04 13:18 bash scripts in Guix question jordi
  2022-10-04 14:10 ` Ekaitz Zarraga
  2022-10-04 14:31 ` Fulbert
@ 2022-10-04 14:38 ` Olivier Dion via
  2022-10-05  3:38   ` Maxim Cournoyer
  2 siblings, 1 reply; 10+ messages in thread
From: Olivier Dion via @ 2022-10-04 14:38 UTC (permalink / raw)
  To: jordi, help-guix

On Tue, 04 Oct 2022, jordi <jordila@librebits.info> 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: bash scripts in Guix question
  2022-10-04 14:38 ` Olivier Dion via
@ 2022-10-05  3:38   ` Maxim Cournoyer
  2022-10-05  3:58     ` Olivier Dion via
  0 siblings, 1 reply; 10+ messages in thread
From: Maxim Cournoyer @ 2022-10-05  3:38 UTC (permalink / raw)
  To: Olivier Dion via; +Cc: jordi, Olivier Dion

Hi,

Olivier Dion via <help-guix@gnu.org> writes:

> On Tue, 04 Oct 2022, jordi <jordila@librebits.info> 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: bash scripts in Guix question
  2022-10-05  3:38   ` Maxim Cournoyer
@ 2022-10-05  3:58     ` Olivier Dion via
  2022-10-05  9:48       ` bash scripts in Guix question - suspend ? jordi
  2022-10-06  0:43       ` bash scripts in Guix question Maxim Cournoyer
  0 siblings, 2 replies; 10+ messages in thread
From: Olivier Dion via @ 2022-10-05  3:58 UTC (permalink / raw)
  To: Maxim Cournoyer, Olivier Dion via; +Cc: jordi

On Tue, 04 Oct 2022, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote:
> Hi,
>
> Olivier Dion via <help-guix@gnu.org> writes:
>
>> On Tue, 04 Oct 2022, jordi <jordila@librebits.info> 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: bash scripts in Guix question - suspend ?
  2022-10-05  3:58     ` Olivier Dion via
@ 2022-10-05  9:48       ` jordi
  2022-10-05 10:29         ` Tobias Geerinckx-Rice
  2022-10-06  0:43       ` bash scripts in Guix question Maxim Cournoyer
  1 sibling, 1 reply; 10+ messages in thread
From: jordi @ 2022-10-05  9:48 UTC (permalink / raw)
  To: help-guix


Thank you all for your warm welcome and answers to my questions.

I'm trying to adapt this script
[..]
	Suspend)
		~/.config/i3/i3exit suspend
[..]

 to my new Guix environment,

in my first iteration,

[..]
	Suspend)
		~/.config/i3/i3exit loginctl suspend
[..]


replacing prepending loginctl leads to unsuccesful results, for now.

I'm puzzled, as long as   'loginctl suspend' is working in the shell ,

What am i missing ?

Thanks, thanks, thanks


On 2022-10-04 23:58:05, Olivier Dion via wrote:
> On Tue, 04 Oct 2022, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote:
> > Hi,
> >
> > Olivier Dion via <help-guix@gnu.org> writes:
> >
> >> On Tue, 04 Oct 2022, jordi <jordila@librebits.info> 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
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: bash scripts in Guix question - suspend ?
  2022-10-05  9:48       ` bash scripts in Guix question - suspend ? jordi
@ 2022-10-05 10:29         ` Tobias Geerinckx-Rice
  0 siblings, 0 replies; 10+ messages in thread
From: Tobias Geerinckx-Rice @ 2022-10-05 10:29 UTC (permalink / raw)
  To: help-guix, jordi

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.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: bash scripts in Guix question
  2022-10-05  3:58     ` Olivier Dion via
  2022-10-05  9:48       ` bash scripts in Guix question - suspend ? jordi
@ 2022-10-06  0:43       ` Maxim Cournoyer
  2022-10-06  0:56         ` Olivier Dion via
  1 sibling, 1 reply; 10+ messages in thread
From: Maxim Cournoyer @ 2022-10-06  0:43 UTC (permalink / raw)
  To: Olivier Dion; +Cc: Olivier Dion via, jordi

Hi,

Olivier Dion <olivier.dion@polymtl.ca> 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: bash scripts in Guix question
  2022-10-06  0:43       ` bash scripts in Guix question Maxim Cournoyer
@ 2022-10-06  0:56         ` Olivier Dion via
  0 siblings, 0 replies; 10+ messages in thread
From: Olivier Dion via @ 2022-10-06  0:56 UTC (permalink / raw)
  To: Maxim Cournoyer; +Cc: Olivier Dion via, jordi

On Wed, 05 Oct 2022, Maxim Cournoyer <maxim.cournoyer@gmail.com> wrote:
> Hi,
>
> Olivier Dion <olivier.dion@polymtl.ca> 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-10-06  0:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-04 13:18 bash scripts in Guix question jordi
2022-10-04 14:10 ` Ekaitz Zarraga
2022-10-04 14:31 ` Fulbert
2022-10-04 14:38 ` Olivier Dion via
2022-10-05  3:38   ` Maxim Cournoyer
2022-10-05  3:58     ` Olivier Dion via
2022-10-05  9:48       ` bash scripts in Guix question - suspend ? jordi
2022-10-05 10:29         ` Tobias Geerinckx-Rice
2022-10-06  0:43       ` bash scripts in Guix question Maxim Cournoyer
2022-10-06  0:56         ` Olivier Dion via

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).