[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

Debbugs page

Simon Tournier wrote 2 years ago
(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
Liliana Marie Prikler wrote 2 years ago
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
zimoun wrote 2 years ago
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
Morgan Smith wrote 2 years ago
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
Ludovic Courtès wrote 2 years ago
(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’.
Ludovic Courtès wrote 2 years ago
(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
?
Your comment

This issue is archived.

To comment on this conversation send an email to 61094@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 61094
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help