unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* environment variable handling cleanup ?
@ 2020-03-22 14:40 Vincent Legoll
  2020-03-23  8:54 ` Hartmut Goebel
  0 siblings, 1 reply; 3+ messages in thread
From: Vincent Legoll @ 2020-03-22 14:40 UTC (permalink / raw)
  To: guix-devel

Hello,

as I'm trying to ramp up my scheme & guix -fu, I'm wondering if
something along the lines of :

  (define* (env-prepend env-var value #:key (separator ":"))
    (let* ((env-val (or (getenv env-var) ""))
           (new-val (if (string-null? env-val)
                      value
                      (string-append value separator env-val))))
      (setenv env-var new-val)))

  (define* (env-append env-var value #:key (separator ":"))
    (let* ((env-val (or (getenv env-var) ""))
           (new-val (if (string-null? env-val)
                      value
                      (string-append env-val separator value))))
      (setenv env-var new-val)))

Would be useful / wanted / controversial ?

My crude approximation tells me there is 1 or 2 hundred such
instances that this could replace.

I expect this would turn ~2 SLOCs into one at each site, so the
gains are not huge compared to the size of guix source code base.

The readability enhancement is also up to debate.

There's also the added (or (getenv ...) "") which is not present in
all target cases.

Another question is the usefulness of the separator parameter,
as I think all target cases use ":", so hardcoding it would be a
sensible choice.

WDYT ?

-- 
Vincent Legoll

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-28  8:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-22 14:40 environment variable handling cleanup ? Vincent Legoll
2020-03-23  8:54 ` Hartmut Goebel
2020-03-28  8:06   ` Vincent Legoll

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).