aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Porter2022-04-01 22:06:02 -0700
committerEli Zaretskii2022-04-17 10:29:07 +0300
commit3dc73569b405d80e89c2965daba31ea4ee6664f0 (patch)
tree5962ada86eaaca6c1748b0abdd5dab619150a8eb
parent6358cbc21a816ac95c2e6e22e087ccd3736874bc (diff)
downloademacs-3dc73569b405d80e89c2965daba31ea4ee6664f0.tar.gz
emacs-3dc73569b405d80e89c2965daba31ea4ee6664f0.zip
Add 'G' argument predicate in Eshell
* lisp/eshell/em-pred.el (eshell-predicate-alist): Add 'G' predicate. (eshell-predicate-help-string): Document it. (Bug#54470) * test/lisp/eshell/em-pred-tests.el (em-pred-test/predicate-effective-gid): New test. * doc/misc/eshell.text (Argument Predication): Document 'G' predicate.
-rw-r--r--doc/misc/eshell.texi3
-rw-r--r--lisp/eshell/em-pred.el9
-rw-r--r--test/lisp/eshell/em-pred-tests.el8
3 files changed, 16 insertions, 4 deletions
diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi
index 2d57e48ed81..411e6960699 100644
--- a/doc/misc/eshell.texi
+++ b/doc/misc/eshell.texi
@@ -1266,6 +1266,9 @@ Matches files with the sticky bit set.
1266@item @samp{U} 1266@item @samp{U}
1267Matches files owned by the current effective user ID. 1267Matches files owned by the current effective user ID.
1268 1268
1269@item @samp{G}
1270Matches files owned by the current effective group ID.
1271
1269@item @samp{l@option{[+-]}@var{n}} 1272@item @samp{l@option{[+-]}@var{n}}
1270Matches files with @var{n} links. With @option{+} (or @option{-}), 1273Matches files with @var{n} links. With @option{+} (or @option{-}),
1271matches files with more than (or less than) @var{n} links, 1274matches files with more than (or less than) @var{n} links,
diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el
index 8afc86dd41a..eb5109b82dc 100644
--- a/lisp/eshell/em-pred.el
+++ b/lisp/eshell/em-pred.el
@@ -88,10 +88,10 @@ ordinary strings."
88 (if (file-exists-p file) 88 (if (file-exists-p file)
89 (= (file-attribute-user-id (file-attributes file)) 89 (= (file-attribute-user-id (file-attributes file))
90 (user-uid))))) 90 (user-uid)))))
91 ;; (?G . (lambda (file) ; owned by effective gid 91 (?G . (lambda (file) ; owned by effective gid
92 ;; (if (file-exists-p file) 92 (if (file-exists-p file)
93 ;; (= (file-attribute-user-id (file-attributes file)) 93 (= (file-attribute-group-id (file-attributes file))
94 ;; (user-uid))))) 94 (group-gid)))))
95 (?* . (lambda (file) 95 (?* . (lambda (file)
96 (and (file-regular-p file) 96 (and (file-regular-p file)
97 (not (file-symlink-p file)) 97 (not (file-symlink-p file))
@@ -161,6 +161,7 @@ PERMISSION BITS (for owner/group/world):
161 161
162OWNERSHIP: 162OWNERSHIP:
163 U owned by effective uid 163 U owned by effective uid
164 G owned by effective gid
164 u(UID|\\='user\\=') owned by UID/user 165 u(UID|\\='user\\=') owned by UID/user
165 g(GID|\\='group\\=') owned by GID/group 166 g(GID|\\='group\\=') owned by GID/group
166 167
diff --git a/test/lisp/eshell/em-pred-tests.el b/test/lisp/eshell/em-pred-tests.el
index 74dad9f8b87..fbf8945215e 100644
--- a/test/lisp/eshell/em-pred-tests.el
+++ b/test/lisp/eshell/em-pred-tests.el
@@ -225,6 +225,14 @@ read, write, and execute predicates to query the file's modes."
225 (should (equal (eshell-eval-predicate files "U") 225 (should (equal (eshell-eval-predicate files "U")
226 '("/fake/uid=1"))))))) 226 '("/fake/uid=1")))))))
227 227
228(ert-deftest em-pred-test/predicate-effective-gid ()
229 "Test that \"G\" matches files owned by the effective GID."
230 (eshell-with-file-attributes-from-name
231 (cl-letf (((symbol-function 'group-gid) (lambda () 1)))
232 (let ((files '("/fake/gid=1" "/fake/gid=2")))
233 (should (equal (eshell-eval-predicate files "G")
234 '("/fake/gid=1")))))))
235
228(ert-deftest em-pred-test/predicate-links () 236(ert-deftest em-pred-test/predicate-links ()
229 "Test that \"l\" filters by number of links." 237 "Test that \"l\" filters by number of links."
230 (eshell-with-file-attributes-from-name 238 (eshell-with-file-attributes-from-name