guix-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] environment: Add a prompt-name argument.


From: Ludovic Courtès
Subject: Re: [PATCH] environment: Add a prompt-name argument.
Date: Mon, 24 Oct 2016 22:40:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hi,

Roel Janssen <address@hidden> skribis:

> This patch adds a -p and --prompt-name argument to @code{guix
> environment}, and puts the argument's value between the square brackets
> instead of "env".

Sounds like a good idea!  Maybe ‘--prompt-suffix’ would be more accurate
a name?  WDYT?

>>From ea958e847019c94a2bde49285f1436dfec72e570 Mon Sep 17 00:00:00 2001
> From: Roel Janssen <address@hidden>
> Date: Thu, 20 Oct 2016 13:07:15 +0200
> Subject: [PATCH] environment: Add a prompt-name argument.
>
> * guix/scripts/environment.scm: Add --prompt-name (-p) argument.

Some cosmetic suggestions follow…  :-)

>  (define* (launch-environment/container #:key command bash user-mappings
> -                                       profile paths network?)
> +                                       profile paths network? prompt-name)

Make it

  (prompt-suffix %default-prompt-suffix)

with:

  (define %default-prompt-suffix
    ;; The default prompt suffix
    " [env]")

such that #:prompt-suffix is always a string.

> +            (setenv "PS1" (string-append "address@hidden \\w ["
> +                                         (if (not prompt-name)
> +                                             "env"
> +                                             prompt-name)

Assume ‘prompt-name’ is a string.

> +    (let* ((opts        (parse-args args))
> +           (pure?       (assoc-ref opts 'pure))
> +           (container?  (assoc-ref opts 'container?))
> +           (network?    (assoc-ref opts 'network?))
> +           (prompt-name (assoc-ref opts 'prompt-name))

I’d change ‘%default-options’ like this:

  (define %default-options
    `(…
      (prompt-suffix . ,%default-prompt-suffix)))

> +                                                  #:prompt-name prompt-name

Maybe add the brackets here?  Like:

  #:prompt-suffix (match prompt-suffix
                    ("" "")  ;allow for an empty suffix
                    ((? string? suffix) (string-append " [" suffix "]")))

Thanks!

Ludo’.



reply via email to

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