unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#30303] [PATCH] linux-boot: Add find-long-options.
@ 2018-01-31 12:29 Danny Milosavljevic
  2018-01-31 22:41 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Danny Milosavljevic @ 2018-01-31 12:29 UTC (permalink / raw)
  To: 30303

* gnu/build/linux/boot.scm (find-long-options): New variable.
---
 gnu/build/linux-boot.scm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 0ab8391b0..b88ce6b99 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -37,6 +37,7 @@
   #:export (mount-essential-file-systems
             linux-command-line
             find-long-option
+            find-long-options
             make-essential-device-nodes
             make-static-device-nodes
             configure-qemu-networking
@@ -99,6 +100,18 @@ Return the value associated with OPTION, or #f on failure."
            (lambda (arg)
              (substring arg (+ 1 (string-index arg #\=)))))))
 
+(define (find-long-options option arguments)
+  "Find OPTIONs among ARGUMENTS, where OPTION is something like \"console\".
+Return the values associated with OPTIONs as a list, or the empty list on
+failure."
+  (let ((opt (string-append option "=")))
+    (map (lambda (arg)
+           (substring arg (+ 1 (string-index arg #\=))))
+         (filter
+           (lambda (arg)
+             (string-prefix? opt arg))
+         arguments))))
+
 (define* (make-disk-device-nodes base major #:optional (minor 0))
   "Make the block device nodes around BASE (something like \"/root/dev/sda\")
 with the given MAJOR number, starting with MINOR."

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

* [bug#30303] [PATCH] linux-boot: Add find-long-options.
  2018-01-31 12:29 [bug#30303] [PATCH] linux-boot: Add find-long-options Danny Milosavljevic
@ 2018-01-31 22:41 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2018-01-31 22:41 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 30303

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> * gnu/build/linux/boot.scm (find-long-options): New variable.

[...]

> +(define (find-long-options option arguments)
> +  "Find OPTIONs among ARGUMENTS, where OPTION is something like \"console\".
> +Return the values associated with OPTIONs as a list, or the empty list on
> +failure."

s/on failure/if OPTION doesn't appear in ARGUMENTS/

> +  (let ((opt (string-append option "=")))
> +    (map (lambda (arg)
> +           (substring arg (+ 1 (string-index arg #\=))))
> +         (filter
> +           (lambda (arg)
> +             (string-prefix? opt arg))
> +         arguments))))

You can make it:

  (filter-map (lambda (arg)
                (and (string-prefix? opt arg)
                     (substring …)))
              arguments)

OK with these changes, thanks!  :-)

Ludo’.

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

end of thread, other threads:[~2018-01-31 22:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-31 12:29 [bug#30303] [PATCH] linux-boot: Add find-long-options Danny Milosavljevic
2018-01-31 22:41 ` Ludovic Courtès

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).