[PATCH] doc: Document 'shebang' for 'guix shell'.

  • Done
  • quality assurance status badge
Details
4 participants
  • Morgan Smith
  • Liliana Marie Prikler
  • Ludovic Courtès
  • Simon Tournier
Owner
unassigned
Submitted by
Simon Tournier
Severity
normal
S
S
Simon Tournier wrote on 27 Jan 2023 12:12
(address . guix-patches@gnu.org)(name . Simon Tournier)(address . zimon.toutoune@gmail.com)
20230127111237.2910126-1-zimon.toutoune@gmail.com
* 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(-)

Toggle diff (37 lines)
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:

base-commit: 8e1cca32b938cef0812ce042c6c2e8bccb326ec7
--
2.38.1
L
L
Liliana Marie Prikler wrote on 3 Feb 2023 23:54
8e79fe217c633650394f2c5199e94e5d0c5a7911.camel@gmail.com
Am Freitag, dem 27.01.2023 um 12:12 +0100 schrieb Simon Tournier:
Toggle quote (39 lines)
> * 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
Z
Z
zimoun wrote on 7 Feb 2023 12:48
Re: [bug#61094] [PATCH] doc: Document 'shebang' for 'guix shell'.
86v8kdn1ax.fsf@gmail.com
Hi,

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

Toggle quote (18 lines)
>> +@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
M
M
Morgan Smith wrote on 9 Feb 2023 17:07
Re: bug#61094: [PATCH] doc: Document 'shebang' for 'guix shell'.
(name . zimoun)(address . zimon.toutoune@gmail.com)
DM5PR03MB3163BD454A5535BB756DA4D8C5D99@DM5PR03MB3163.namprd03.prod.outlook.com
Hello,

Toggle quote (4 lines)
>>> +@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
L
L
Ludovic Courtès wrote on 16 Mar 2023 12:09
(name . Morgan Smith)(address . Morgan.J.Smith@outlook.com)
87zg8deyw8.fsf_-_@gnu.org
Hi,

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

Toggle quote (11 lines)
>>>> +@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’.
L
L
Ludovic Courtès wrote on 16 Mar 2023 12:21
(name . Simon Tournier)(address . zimon.toutoune@gmail.com)(address . 61094-done@debbugs.gnu.org)
87v8j1eyaw.fsf@gnu.org
Hi Simon,

Simon Tournier <zimon.toutoune@gmail.com> skribis:

Toggle quote (3 lines)
> * doc/guix.texi (Invoking guix shell): Add a note mentioning how to use
> 'shebang'.

Applied with the changes below.

Thanks!

Ludo’.
Toggle diff (30 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 9c1fc04265..aa98d7df4b 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5940,16 +5940,19 @@ 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,
+@cindex shebang, for @command{guix shell}
+@command{guix shell} can be also be used as a script interpreter, also
+known as @dfn{shebang}. Here is an example self-contained Python script
+making use of this feature:
@example
-#!/usr/bin/env -S guix shell python python-nympy -- python3
+#!/usr/bin/env -S guix shell python python-numpy -- python3
+import numpy
+print("This is numpy", numpy.version.version)
@end example
-All the @var{options} or convenience of @command{guix shell} apply.
+You may pass any @command{guix shell} option, but there's one caveat:
+the Linux kernel has a limit of 127 bytes on shebang length.
@end quotation
Development environments can be created as in the example below, which
Closed
?