guix-commits
[Top][All Lists]
Advanced

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

02/03: bournish: Add 'reboot' command.


From: Ludovic Courtès
Subject: 02/03: bournish: Add 'reboot' command.
Date: Mon, 10 Oct 2016 20:18:01 +0000 (UTC)

civodul pushed a commit to branch master
in repository guix.

commit 813bcbc4eaa820821c3fc52e539c5244e192601c
Author: Ludovic Courtès <address@hidden>
Date:   Mon Oct 10 09:57:36 2016 +0200

    bournish: Add 'reboot' command.
    
    Suggested by Ricardo Wurmus.
    
    * guix/build/bournish.scm (reboot-command): New procedure.
    (%commands): Add it.
---
 guix/build/bournish.scm |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/guix/build/bournish.scm b/guix/build/bournish.scm
index 928bef5..51dad17 100644
--- a/guix/build/bournish.scm
+++ b/guix/build/bournish.scm
@@ -162,6 +162,17 @@ characters."
         (else
          `((@@ (guix build bournish) wc-command-implementation) ,@args))))
 
+(define (reboot-command . args)
+  "Emit code for 'reboot'."
+  ;; Normally Bournish is used in the initrd, where 'reboot' is provided
+  ;; directly by (guile-user).  In other cases, just bail out.
+  `(if (defined? 'reboot)
+       (reboot)
+       (begin
+         (format (current-error-port)
+                 "I don't know how to reboot, sorry about that!~%")
+         #f)))
+
 (define (help-command . _)
   (display "\
 Hello, this is Bournish, a minimal Bourne-like shell in Guile!
@@ -189,7 +200,8 @@ commands such as 'ls' and 'cd'; it lacks globbing, 
pipes---everything.\n"))
     ("ls"     ,ls-command)
     ("which"  ,which-command)
     ("cat"    ,cat-command)
-    ("wc"     ,wc-command)))
+    ("wc"     ,wc-command)
+    ("reboot" ,reboot-command)))
 
 (define (read-bournish port env)
   "Read a Bournish expression from PORT, and return the corresponding Scheme



reply via email to

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