Function: eshell/umask

eshell/umask is a byte-compiled function defined in em-basic.el.gz.

Signature

(eshell/umask &rest ARGS)

Documentation

Shell-like implementation of umask.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-basic.el.gz
(defun eshell/umask (&rest args)
  "Shell-like implementation of `umask'."
  (eshell-eval-using-options
   "umask" args
   '((?S "symbolic" nil symbolic-p "display umask symbolically")
     (?h "help" nil nil  "display this usage message")
     :preserve-args
     :usage "[-S] [mode]")
   (cond
    (symbolic-p
     (let ((mode (default-file-modes)))
       (eshell-printn
        (format "u=%s,g=%s,o=%s"
                (concat (and (= (logand mode 64) 64) "r")
                        (and (= (logand mode 128) 128) "w")
                        (and (= (logand mode 256) 256) "x"))
                (concat (and (= (logand mode 8) 8) "r")
                        (and (= (logand mode 16) 16) "w")
                        (and (= (logand mode 32) 32) "x"))
                (concat (and (= (logand mode 1) 1) "r")
                        (and (= (logand mode 2) 2) "w")
                        (and (= (logand mode 4) 4) "x"))))))
    ((not args)
     (eshell-printn (format "%03o" (logand (lognot (default-file-modes))
                                           #o777))))
    (t
     (when (stringp (car args))
       (if (string-match "^[0-7]+$" (car args))
           (setcar args (string-to-number (car args) 8))
         (error "Setting umask symbolically is not yet implemented")))
     (set-default-file-modes (- #o777 (car args)))
     (eshell-print
      "Warning: umask changed for all new files created by Emacs.\n")))
   nil))