diff mbox series

[bug#61094] doc: Document 'shebang' for 'guix shell'.

Message ID 20230127111237.2910126-1-zimon.toutoune@gmail.com
State New
Headers show
Series [bug#61094] doc: Document 'shebang' for 'guix shell'. | expand

Commit Message

Simon Tournier Jan. 27, 2023, 11:12 a.m. UTC
* doc/guix.texi (Invoking guix shell): Add a note mentioning how to use
'shebang'.
---
 doc/guix.texi | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)


base-commit: 8e1cca32b938cef0812ce042c6c2e8bccb326ec7

Comments

Liliana Marie Prikler Feb. 3, 2023, 10:54 p.m. UTC | #1
Am Freitag, dem 27.01.2023 um 12:12 +0100 schrieb Simon Tournier:
> * doc/guix.texi (Invoking guix shell): Add a note mentioning how to
> use
> 'shebang'.
> ---
>  doc/guix.texi | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 2b1ad77ba5..acda01c8e6 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -71,7 +71,7 @@ Copyright @copyright{} 2019 Kyle Andrews@*
>  Copyright @copyright{} 2019 Alex Griffin@*
>  Copyright @copyright{} 2019, 2020, 2021, 2022 Guillaume Le
> Vaillant@*
>  Copyright @copyright{} 2020 Liliana Marie Prikler@*
> -Copyright @copyright{} 2019, 2020, 2021, 2022 Simon Tournier@*
> +Copyright @copyright{} 2019, 2020, 2021, 2022, 2023 Simon Tournier@*
>  Copyright @copyright{} 2020 Wiktor Żelazny@*
>  Copyright @copyright{} 2020 Damien Cassou@*
>  Copyright @copyright{} 2020 Jakub Kądziołka@*
> @@ -5923,6 +5923,19 @@ building or downloading any missing package,
> and runs the
>  guix shell python python-numpy -- python3
>  @end example
>  
> +@quotation Note
> +@cindex shebang
> +@command{guix shell} can be used as @emph{shebang}.  Consider the
> +previous example as an executable Python script, the @emph{shebang}
> +reads,
> +
> +@example
> +#!/usr/bin/env -S guix shell python python-nympy -- python3
> +@end example
> +
> +All the @var{options} or convenience of @command{guix shell} apply.
> +@end quotation
> +
Is this really guix running as a shell or is it actually a feature of
env?  In either case, it's worth documenting, but we should try to stay
factually correct.

Cheers
Simon Tournier Feb. 7, 2023, 11:48 a.m. UTC | #2
Hi,

On Fri, 03 Feb 2023 at 23:54, Liliana Marie Prikler <liliana.prikler@gmail.com> wrote:

>> +@quotation Note
>> +@cindex shebang
>> +@command{guix shell} can be used as @emph{shebang}.  Consider the
>> +previous example as an executable Python script, the @emph{shebang}
>> +reads,
>> +
>> +@example
>> +#!/usr/bin/env -S guix shell python python-nympy -- python3
>> +@end example
>> +
>> +All the @var{options} or convenience of @command{guix shell} apply.
>> +@end quotation
>> +
>
> Is this really guix running as a shell or is it actually a feature of
> env?  In either case, it's worth documenting, but we should try to stay
> factually correct.

Well, I am not sure to understand the question.  It is a feature of env
which allows to run “guix shell” which provides python3 as “shell”.

From my understanding, all written seems factually correct.  Maybe I am
missing something and I would be happy to be corrected if I am doing
wrong. :-)

Cheers,
simon
Morgan Smith Feb. 9, 2023, 4:07 p.m. UTC | #3
Hello,

>>> +@example
>>> +#!/usr/bin/env -S guix shell python python-nympy -- python3
>>> +@end example

Apparently, according to POSIX you're only allowed one argument on the
'#!' line after the path of the executable.  I haven't confirmed this
myself but it is in the guile manual, section 4.3.2 "The Meta Switch".

One argument does seem quite limiting though so I wonder if anyone
actually imposes that limit.


Morgan
Ludovic Courtès March 16, 2023, 11:09 a.m. UTC | #4
Hi,

Morgan Smith <Morgan.J.Smith@outlook.com> skribis:

>>>> +@example
>>>> +#!/usr/bin/env -S guix shell python python-nympy -- python3
>>>> +@end example
>
> Apparently, according to POSIX you're only allowed one argument on the
> '#!' line after the path of the executable.  I haven't confirmed this
> myself but it is in the guile manual, section 4.3.2 "The Meta Switch".
>
> One argument does seem quite limiting though so I wonder if anyone
> actually imposes that limit.

Yes, and ‘env -S’ is used to work around that limitation by splitting
that one argument.  It’s a GNU extension, which is fine in this context.

Ludo’.
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 2b1ad77ba5..acda01c8e6 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -71,7 +71,7 @@  Copyright @copyright{} 2019 Kyle Andrews@*
 Copyright @copyright{} 2019 Alex Griffin@*
 Copyright @copyright{} 2019, 2020, 2021, 2022 Guillaume Le Vaillant@*
 Copyright @copyright{} 2020 Liliana Marie Prikler@*
-Copyright @copyright{} 2019, 2020, 2021, 2022 Simon Tournier@*
+Copyright @copyright{} 2019, 2020, 2021, 2022, 2023 Simon Tournier@*
 Copyright @copyright{} 2020 Wiktor Żelazny@*
 Copyright @copyright{} 2020 Damien Cassou@*
 Copyright @copyright{} 2020 Jakub Kądziołka@*
@@ -5923,6 +5923,19 @@  building or downloading any missing package, and runs the
 guix shell python python-numpy -- python3
 @end example
 
+@quotation Note
+@cindex shebang
+@command{guix shell} can be used as @emph{shebang}.  Consider the
+previous example as an executable Python script, the @emph{shebang}
+reads,
+
+@example
+#!/usr/bin/env -S guix shell python python-nympy -- python3
+@end example
+
+All the @var{options} or convenience of @command{guix shell} apply.
+@end quotation
+
 Development environments can be created as in the example below, which
 spawns an interactive shell containing all the dependencies and
 environment variables needed to work on Inkscape: