Function: exec-path-from-shell-getenvs--nushell
exec-path-from-shell-getenvs--nushell is a natively compiled function
defined in exec-path-from-shell.el.
Signature
(exec-path-from-shell-getenvs--nushell NAMES)
Documentation
Use nushell to get the value of env vars with the given NAMES.
Execute the shell according to exec-path-from-shell-arguments.
The result is a list of (NAME . VALUE) pairs.
Nushell sometimes produces output like e.g. flag deprecation warnings. These messages are written to an error buffer (*exec-path-from-shell: nushell errors*); unless Nushell produces a non-zero exit code, this buffer is left undisplayed.
Source Code
;; Defined in /nix/store/a3f7aq5s6rdw5arrqvyppbs5jfrlsxa3-emacs-packages-deps/share/emacs/site-lisp/elpa/exec-path-from-shell-20260423.1833/exec-path-from-shell.el
(defun exec-path-from-shell-getenvs--nushell (names)
"Use nushell to get the value of env vars with the given NAMES.
Execute the shell according to `exec-path-from-shell-arguments'.
The result is a list of (NAME . VALUE) pairs.
Nushell sometimes produces output like e.g. flag deprecation warnings.
These messages are written to an error buffer (*exec-path-from-shell:
nushell errors*); unless Nushell produces a non-zero exit code, this
buffer is left undisplayed."
(let* ((shell (exec-path-from-shell--shell))
(expr (format "[ %s ] | to json"
(string-join
(mapcar (lambda (name)
(format "$env.%s?" (exec-path-from-shell--double-quote name)))
names)
", ")))
(shell-args (append exec-path-from-shell-arguments (list "-c" expr)))
(err-buff-name "*exec-path-from-shell: nushell errors*")
(err-file (make-temp-file err-buff-name)))
(with-temp-buffer
(when (get-buffer err-buff-name) (kill-buffer err-buff-name))
(exec-path-from-shell--debug "Invoking shell %s with args %S" shell shell-args)
(let ((exit-code (exec-path-from-shell--warn-duration
(apply #'call-process shell nil `(t ,err-file) nil shell-args)))
(err-buff (generate-new-buffer err-buff-name)))
(exec-path-from-shell--debug "Shell printed: %S" (buffer-string))
(with-current-buffer err-buff (insert-file-contents err-file))
(unless (zerop exit-code)
(error "Non-zero exit code from shell %s invoked with args %S. Output was:\n%S"
shell shell-args (buffer-string))
(display-buffer err-buff)))
(goto-char (point-min))
(let ((json-array-type 'list)
(json-null :null))
(let ((values (json-read-array))
result)
(while values
(let ((value (car values)))
(push (cons (car names)
(unless (eq :null value)
(if (listp value)
(string-join value path-separator)
value)))
result))
(setq values (cdr values)
names (cdr names)))
result)))))