* 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.
@item @samp{U}
Matches files owned by the current effective user ID.
+@item @samp{G}
+Matches files owned by the current effective group ID.
+
@item @samp{l@option{[+-]}@var{n}}
Matches files with @var{n} links. With @option{+} (or @option{-}),
matches files with more than (or less than) @var{n} links,
(if (file-exists-p file)
(= (file-attribute-user-id (file-attributes file))
(user-uid)))))
- ;; (?G . (lambda (file) ; owned by effective gid
- ;; (if (file-exists-p file)
- ;; (= (file-attribute-user-id (file-attributes file))
- ;; (user-uid)))))
+ (?G . (lambda (file) ; owned by effective gid
+ (if (file-exists-p file)
+ (= (file-attribute-group-id (file-attributes file))
+ (group-gid)))))
(?* . (lambda (file)
(and (file-regular-p file)
(not (file-symlink-p file))
OWNERSHIP:
U owned by effective uid
+ G owned by effective gid
u(UID|\\='user\\=') owned by UID/user
g(GID|\\='group\\=') owned by GID/group
(should (equal (eshell-eval-predicate files "U")
'("/fake/uid=1")))))))
+(ert-deftest em-pred-test/predicate-effective-gid ()
+ "Test that \"G\" matches files owned by the effective GID."
+ (eshell-with-file-attributes-from-name
+ (cl-letf (((symbol-function 'group-gid) (lambda () 1)))
+ (let ((files '("/fake/gid=1" "/fake/gid=2")))
+ (should (equal (eshell-eval-predicate files "G")
+ '("/fake/gid=1")))))))
+
(ert-deftest em-pred-test/predicate-links ()
"Test that \"l\" filters by number of links."
(eshell-with-file-attributes-from-name