GNU bug report logs

#54469 home-environment-variables-service-type does not quote things

PackageSource(s)Maintainer(s)
guix PTS Buildd Popcon
Reply or subscribe to this bug. View this bug as an mbox, status mbox, or maintainer mbox

Report forwarded to bug-guix@gnu.org:
bug#54469; Package guix. (Sat, 19 Mar 2022 21:06:02 GMT) (full text, mbox, link).


Acknowledgement sent to Maxime Devos <maximedevos@telenet.be>:
New bug report received and forwarded. Copy sent to bug-guix@gnu.org. (Sat, 19 Mar 2022 21:06:02 GMT) (full text, mbox, link).


Message #5 received at submit@debbugs.gnu.org (full text, mbox, reply):

From: Maxime Devos <maximedevos@telenet.be>
To: bug-guix@gnu.org
Subject: home-environment-variables-service-type does not quote things
Date: Sat, 19 Mar 2022 22:04:59 +0100
[Message part 1 (text/plain, inline)]
Hi guix,

Consider the following home configuration:

(use-modules (gnu home) (gnu packages) (gnu home services)
             (gnu services) (guix gexp) (gnu home services shells))

(define formula-of-the-day
   ;; TODO: add some more formulae, randomise
   "$US dollar/€euro = 1.11")

(home-environment
  (packages '())
  (services
    (list (simple-service 'extra-environment-variables
                        home-environment-variables-service-type
                        `(("formula of the (reconfiguration) day" . ,formula-of-the-day))))))

Now start a container with this configuration with "guix home container":

$ guix home container home-configuration.scm

[start output block]
WARNING: (guile-user): imported module (guix build utils) overrides
core binding `delete'
/gnu/store/[...]/setup-environment: line 33: syntax error near
unexpected token `('
/gnu/store/[...]/setup-environment: line 33: `export formula of the
(reconfiguration) day=$US dollar/€euro = 1.11'
Backtrace:
In ice-9/boot-9.scm:
  1752:10 11 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
          10 (apply-smob/0 #<thunk 7f8d3bd36f40>)
In ice-9/boot-9.scm:
    724:2  9 (call-with-prompt _ _ #<procedure default-prompt-handle?>)
In ice-9/eval.scm:
    619:8  8 (_ #(#(#<directory (guile-user) 7f8d3bd30c80>)))
In ice-9/command-line.scm:
   185:18  7 (_ #<input: string 7f8d3bd29850>)
In unknown file:
           6 (eval (begin (use-modules (guix build utils) (# ?) ?) ?)
?)
In ice-9/eval.scm:
    619:8  5 (_ #f)
In unknown file:
           4 (primitive-load "/gnu/store/6xn1fyljn05cjgx3sakhmds88sc?")
In ice-9/eval.scm:
   293:34  3 (_ #(#(#(#(#(#(#(#(#<directory ?> ?) ?) ?) ?) ?) ?) ?) ?))
    159:9  2 (_ #(#(#(#(#(#(#(#(#<directory ?> ?) ?) ?) ?) ?) ?) ?) ?))
    159:9  1 (_ #(#(#(#(#(#(#(#(#<directory ?> ?) ?) ?) ?) ?) ?) ?) ?))
In unknown file:
           0 (string-split #<eof> #\nul)

ERROR: In procedure string-split:
In procedure string-split: Wrong type argument in position 1 (expecting
string): #<eof>
[end output block]

To investigate, I took a look at 'setup-environment':

   [lots of exports]
   export formula of the (reconfiguration) day=$US dollar/€euro = 1.11

There are at least two issues here:

  * The variable 'formula of the (reconfiguration) day' was not quoted.

    I don't know how to do this in bash though, if it is even possible
    at all.  If it turns out not to be possible, I'd prefer that to
    be mentioned by a nice error message, e.g. "environment variable
    names may not contain FOOs" or "environment variable names must
    consist of BARs".

  * The value '$US dollar/€euro' was not quoted, so bash would
    expand $US (to the empty string, since $US is not defined).

Greetings,
Maxime.
[signature.asc (application/pgp-signature, inline)]

Severity set to 'important' from 'normal' Request was from Ludovic Courtès <ludo@gnu.org> to control@debbugs.gnu.org. (Thu, 07 Apr 2022 16:47:01 GMT) (full text, mbox, link).


Information forwarded to bug-guix@gnu.org:
bug#54469; Package guix. (Wed, 13 Jul 2022 23:14:02 GMT) (full text, mbox, link).


Message #10 received at 54469@debbugs.gnu.org (full text, mbox, reply):

From: Ludovic Courtès <ludo@gnu.org>
To: Maxime Devos <maximedevos@telenet.be>
Cc: 54469@debbugs.gnu.org
Subject: Re: bug#54469: home-environment-variables-service-type does not quote things
Date: Thu, 14 Jul 2022 01:13:16 +0200
Hi,

Maxime Devos <maximedevos@telenet.be> skribis:

> (use-modules (gnu home) (gnu packages) (gnu home services)
>              (gnu services) (guix gexp) (gnu home services shells))
>
> (define formula-of-the-day
>    ;; TODO: add some more formulae, randomise
>    "$US dollar/€euro = 1.11")
>
> (home-environment
>   (packages '())
>   (services
>     (list (simple-service 'extra-environment-variables
>                         home-environment-variables-service-type
>                         `(("formula of the (reconfiguration) day" . ,formula-of-the-day))))))

Fixed in af4c103595a725194318f40fc5aba110772ff417… except for checking
the name of the variable.

I guess we should stick to the grammar for “names” that Bash defines
(info "(bash) Definitions") and error out if the variable name doesn’t
comply?

Ludo’.




Information forwarded to bug-guix@gnu.org:
bug#54469; Package guix. (Thu, 21 Jul 2022 12:31:02 GMT) (full text, mbox, link).


Message #13 received at 54469@debbugs.gnu.org (full text, mbox, reply):

From: Maxime Devos <maximedevos@telenet.be>
To: Ludovic Courtès <ludo@gnu.org>
Cc: 54469@debbugs.gnu.org
Subject: Re: bug#54469: home-environment-variables-service-type does not quote things
Date: Thu, 21 Jul 2022 14:30:39 +0200
[Message part 1 (text/plain, inline)]
On 14-07-2022 01:13, Ludovic Courtès wrote:
> [...]
> Fixed in af4c103595a725194318f40fc5aba110772ff417… except for checking
> the name of the variable.
>
> I guess we should stick to the grammar for “names” that Bash defines
> (info "(bash) Definitions") and error out if the variable name doesn’t
> comply?

Yes -- supporting arbitrary variable names would be nice but that just 
sticking to those (and erroring out) should be good enough in practice.

FWIW, (guix search-paths) also does export this="that", so it looks like 
the quoting and name checking could be generalised a little to also 
extend to etc/profile.

Greetings,
Maxime.

[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

Send a report that this bug log contains spam.


debbugs.gnu.org maintainers <help-debbugs@gnu.org>. Last modified: Sun Sep 8 03:10:46 2024; Machine Name: wallace-server

GNU bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.