From 9a34a056f34335b5b1e4dde7f6e0b8ea28b27434 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 25 Nov 2022 11:03:55 -0700 Subject: add REMOTE-EXISTS-{EVERY,SOME}-P, fix docstring grammar Thanks to David Bremner for suggesting the names of the new functions. Signed-off-by: Sean Whitton --- src/connection.lisp | 21 +++++++++++++++++---- src/package.lisp | 2 ++ 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/connection.lisp b/src/connection.lisp index d051ad6..68a1404 100644 --- a/src/connection.lisp +++ b/src/connection.lisp @@ -542,12 +542,25 @@ subclass to the :HOSTATTRS subroutine of properties calling this." (alet (sh-escape (drop-trailing-slash (unix-namestring directory))) (mrun (format nil "rm -rf -- ~A/* ~A/.[!.]* ~A/..?*" it it it)))) +(defun remote-test-multiple (operator paths connective) + (apply #'remote-test (loop for path on paths + nconc (list operator (car path)) + when (cdr path) collect connective))) + (defun remote-exists-p (&rest paths) - "Does each of PATHS exists? + "Does each of PATHS exist? PATH may be any kind of file, including directories." - (apply #'remote-test (loop for path on paths - nconc (list "-e" (car path)) - when (cdr path) collect "-a"))) + (remote-test-multiple "-e" paths "-a")) + +(defun remote-exists-every-p (&rest paths) + "Does each of PATHS exist? +PATH may be any kind of file, including directories." + (remote-test-multiple "-e" paths "-a")) + +(defun remote-exists-some-p (&rest paths) + "Do any of PATHS exist? +PATH may be any kind of file, including directories." + (remote-test-multiple "-e" paths "-o")) (defun remote-file-stats (path) "Get the numeric mode, size in bytes, mtime, owner and group of PATH, or NIL if diff --git a/src/package.lisp b/src/package.lisp index db29898..a576d3c 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -188,6 +188,8 @@ #:runlines #:remote-test #:remote-exists-p + #:remote-exists-every-p + #:remote-exists-some-p #:remote-file-stats #:remote-last-reboot #:remote-executable-find -- cgit v1.2.3