Function: tramp-maybe-send-script

tramp-maybe-send-script is a byte-compiled function defined in tramp-sh.el.gz.

Signature

(tramp-maybe-send-script VEC SCRIPT NAME)

Documentation

Define in remote shell function NAME implemented as SCRIPT.

Only send the definition if it has not already been done.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-sh.el.gz
(defun tramp-maybe-send-script (vec script name)
  "Define in remote shell function NAME implemented as SCRIPT.
Only send the definition if it has not already been done."
  ;; We cannot let-bind (tramp-get-connection-process vec) because it
  ;; might be nil.
  (let ((scripts (tramp-get-connection-property
		  (tramp-get-connection-process vec) "scripts")))
    (unless (member name scripts)
      (with-tramp-progress-reporter
	  vec 5 (format-message "Sending script `%s'" name)
	;; In bash, leading TABs like in `tramp-bundle-read-file-names'
	;; could result in unwanted command expansion.  Avoid this.
	(setq script (tramp-compat-string-replace
		      (make-string 1 ?\t) (make-string 8 ? ) script))
	;; Expand format specifiers.
	(unless (setq script (tramp-expand-script vec script))
	  (tramp-error
	   vec 'file-error
	   (format "Script %s is not applicable on remote host" name)))
	;; Send it.
	(tramp-barf-unless-okay
	 vec
	 (format "%s () {\n%s\n}" name script)
	 "Script %s sending failed" name)
	(tramp-set-connection-property
	 (tramp-get-connection-process vec) "scripts" (cons name scripts))))))