mkdir: New builtin.
* gash/commands/mkdir.scm: New file. * build-aux/build-guile.sh: Compile it. * configure: Create script. * gash/bournish-commands.scm (mkdir-command): New variable. (%bournish-commands): Add it.
This commit is contained in:
parent
678e192b4f
commit
f62e6e99a7
|
@ -9,6 +9,7 @@
|
|||
/bin/gash
|
||||
/bin/grep
|
||||
/bin/ls
|
||||
/bin/mkdir
|
||||
/bin/reboot
|
||||
/bin/rm
|
||||
/bin/sed
|
||||
|
|
|
@ -56,6 +56,7 @@ ${srcdest}gash/commands/cp.scm
|
|||
${srcdest}gash/commands/find.scm
|
||||
${srcdest}gash/commands/grep.scm
|
||||
${srcdest}gash/commands/ls.scm
|
||||
${srcdest}gash/commands/mkdir.scm
|
||||
${srcdest}gash/commands/reboot.scm
|
||||
${srcdest}gash/commands/rm.scm
|
||||
${srcdest}gash/commands/sed.scm
|
||||
|
@ -74,6 +75,7 @@ ${srcdest}bin/find
|
|||
${srcdest}bin/gash
|
||||
${srcdest}bin/grep
|
||||
${srcdest}bin/ls
|
||||
${srcdest}bin/mkdir
|
||||
${srcdest}bin/reboot
|
||||
${srcdest}bin/rm
|
||||
${srcdest}bin/sed
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
(define find-command (wrap-command "find" find))
|
||||
(define grep-command (wrap-command "grep" grep))
|
||||
(define ls-command (wrap-command "ls" ls))
|
||||
(define mkdir-command (wrap-command "mkdir" mkdir))
|
||||
(define reboot-command (wrap-command "reboot" reboot'))
|
||||
(define rm-command (wrap-command "rm" rm))
|
||||
(define sed-command (wrap-command "sed" sed))
|
||||
|
@ -92,6 +93,7 @@
|
|||
("find" . ,find-command)
|
||||
("grep" . ,grep-command)
|
||||
("ls" . ,ls-command)
|
||||
("mkdir" . ,mkdir)
|
||||
("reboot" . ,reboot-command)
|
||||
("rm" . ,rm-command)
|
||||
("sed" . ,sed-command)
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
;;; Gash -- Guile As SHell
|
||||
;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of Gash.
|
||||
;;;
|
||||
;;; Gash is free software; you can redistribute it and/or modify it
|
||||
;;; under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 3 of the License, or (at
|
||||
;;; your option) any later version.
|
||||
;;;
|
||||
;;; Gash is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
;;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
;;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
;;; details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
(define-module (gash commands mkdir)
|
||||
#:use-module (ice-9 getopt-long)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (ice-9 receive)
|
||||
#:use-module (ice-9 regex)
|
||||
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-9 gnu)
|
||||
#:use-module (srfi srfi-26)
|
||||
|
||||
#:use-module (gash config)
|
||||
#:use-module (gash guix-utils)
|
||||
#:use-module (gash shell-utils)
|
||||
|
||||
#:export (
|
||||
mkdir
|
||||
))
|
||||
|
||||
(define (mkdir . args)
|
||||
(let* ((option-spec
|
||||
'((help (single-char #\h))
|
||||
(mode (single-char #\m) (value #t))
|
||||
(parents (single-char #\p))
|
||||
(version (single-char #\V))))
|
||||
(options (getopt-long args option-spec))
|
||||
(files (option-ref options '() '()))
|
||||
(mode (option-ref options 'mode #f))
|
||||
(parents? (option-ref options 'parents #f))
|
||||
(help? (option-ref options 'help #f))
|
||||
(version? (option-ref options 'version #f))
|
||||
(files (option-ref options '() '()))
|
||||
(usage? (and (not help?) (null? files))))
|
||||
(cond (version? (format #t "mkdir (GASH) ~a\n" %version) (exit 0))
|
||||
((or help? usage?) (format (if usage? (current-error-port) #t)
|
||||
"\
|
||||
Usage: mkdir [OPTION]... DIRECTORY...
|
||||
Create the DIRECTORY(ies), if they do not already exist.
|
||||
|
||||
Options:
|
||||
--help display this help and exit
|
||||
-m, --mode=MODE set file mode (as in chmod), not a=rwx - umask
|
||||
-p, --parents no error if existing, make parent directories as needed
|
||||
--version output version information and exit
|
||||
|
||||
")
|
||||
(exit (if usage? 2 0)))
|
||||
(else
|
||||
(let ((mode (if mode (umask (chmodifiers->mode (parse-modifiers mode)))
|
||||
#o755)))
|
||||
(for-each (if parents? mkdir-p (@ (guile) mkdir)) files))))))
|
||||
|
||||
(define main mkdir)
|
Loading…
Reference in New Issue