Function: eshell--invoke-command-directly

eshell--invoke-command-directly is a byte-compiled function defined in esh-cmd.el.gz.

Signature

(eshell--invoke-command-directly COMMAND)

Documentation

Determine whether the given COMMAND can be invoked directly.

COMMAND should be a non-top-level Eshell command in parsed form.

A command can be invoked directly if all of the following are true:

* The command is of the form
  "(eshell-trap-errors (eshell-named-command NAME ARGS))",
  where ARGS is optional.

* NAME is a string referring to an alias function and isn't a
  complex command (see eshell-complex-commands).

* Any subcommands in ARGS can also be invoked directly.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-cmd.el.gz
(defun eshell--invoke-command-directly (command)
  "Determine whether the given COMMAND can be invoked directly.
COMMAND should be a non-top-level Eshell command in parsed form.

A command can be invoked directly if all of the following are true:

* The command is of the form
  \"(eshell-trap-errors (eshell-named-command NAME ARGS))\",
  where ARGS is optional.

* NAME is a string referring to an alias function and isn't a
  complex command (see `eshell-complex-commands').

* Any subcommands in ARGS can also be invoked directly."
  (when (and (eq (car command) 'eshell-trap-errors)
             (eq (car (cadr command)) 'eshell-named-command))
    (let ((name (cadr (cadr command)))
          (args (cdr-safe (nth 2 (cadr command)))))
      (and name (stringp name)
	   (not (member name eshell-complex-commands))
	   (catch 'simple
	     (dolist (pred eshell-complex-commands t)
	       (when (and (functionp pred)
                          (funcall pred name))
                 (throw 'simple nil))))
	   (eshell-find-alias-function name)
           (catch 'indirect-subcommand
             (iter-do (subcommand (eshell--find-subcommands args))
               (unless (eshell--invoke-command-directly subcommand)
                 (throw 'indirect-subcommand nil)))
             t)))))