guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#50960] ‘guix shell’ shebangs


From: Ludovic Courtès
Subject: [bug#50960] ‘guix shell’ shebangs
Date: Sat, 02 Oct 2021 16:00:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Ludovic Courtès <ludo@gnu.org> skribis:

> The differences to ‘guix environment’ are:
>
>   1. ‘--ad-hoc’ is the default.
>
>        ‘guix shell hello’ ≍ ‘guix environment --ad-hoc hello’
>        ‘guix shell -D hello git’ ≍ ‘guix environment hello --ad-hoc git’
>
>   2. ‘guix shell’, without arguments, loads ‘guix.scm’ or ‘manifest.scm’
>      from the current directory or one of its ancestors.
>
>   3. ‘--load’/‘-l’ is not ‘-f’/‘--install-from-file’ for consistency with
>      ‘guix package’.
>
>   4. ‘guix shell’ without arguments maintains a cache, such that, the
>      second time you run it, it runs in ~0.1s (it does not even need to
>      connect to the daemon).
>
>      If you run ‘guix pull’ and run again ‘guix shell’, it recomputes
>      the environment, as is currently the case with ‘guix environment’.

Oh, I had another goal in mind, which was to make it easy to use ‘guix
shell’ in shebangs.

Problem is, since it’s called ‘guix shell’ and not ‘guix-shell’, we have
to use ‘/usr/bin/env -S’ anyway as the shebang so it splits arguments.
And with ‘-S’, we can already do pretty much everything we want.  Here’s
a shell script:

--8<---------------cut here---------------start------------->8---
$ cat t.sh
#!/usr/bin/env -S guix shell hello bash -- sh
type -P hello
hello
--8<---------------cut here---------------end--------------->8---

Should we simply document it or should we do something more?

For the record, ‘nix-shell’ has shebang support where it can interpret
“special” lines as arguments:

  https://nixos.org/manual/nix/stable/#sec-nix-shell

Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]