[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master e074081af3d: Add special '$GID' variable in Eshell
From: |
Jim Porter |
Subject: |
master e074081af3d: Add special '$GID' variable in Eshell |
Date: |
Sat, 8 Jul 2023 15:21:35 -0400 (EDT) |
branch: master
commit e074081af3de6bbdff330f6fa60355b3a86215bb
Author: Jim Porter <jporterbugs@gmail.com>
Commit: Jim Porter <jporterbugs@gmail.com>
Add special '$GID' variable in Eshell
See bug#64529.
* lisp/eshell/esh-var.el (eshell-variable-aliases-list): Add '$GID'.
* test/lisp/eshell/esh-var-tests.el (esh-var-test/gid-var): New test.
* doc/misc/eshell.texi (Variables): Document '$GID'.
* etc/NEWS: Announce this change (and the previous change for '$UID').
---
doc/misc/eshell.texi | 7 +++++++
etc/NEWS | 5 +++++
lisp/eshell/esh-var.el | 1 +
test/lisp/eshell/esh-var-tests.el | 4 ++++
4 files changed, 17 insertions(+)
diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi
index 6e92d598387..c6376882542 100644
--- a/doc/misc/eshell.texi
+++ b/doc/misc/eshell.texi
@@ -993,6 +993,13 @@ variable is connection-aware, so when the current
directory is remote,
its value will be @acronym{UID} for the user associated with that
remote connection.
+@vindex $GID
+@item $GID
+This returns the effective @acronym{GID} for the current user. Like
+@code{$UID}, this variable is connection-aware, so when the current
+directory is remote, its value will be @acronym{GID} for the user
+associated with that remote connection.
+
@vindex $_
@item $_
This refers to the last argument of the last command. With a
diff --git a/etc/NEWS b/etc/NEWS
index 0556e8be585..246e6b21838 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -202,6 +202,11 @@ or get a sublist of elements 2 through 4 with
'$my-list[2..5]'. For
more information, see the "(eshell) Dollars Expansion" node in the
Eshell manual.
++++
+*** Eshell's '$UID' and '$GID' variables are now connection-aware.
+Now, when expanding '$UID' or '$GID' in a remote directory, the value
+is the user or group ID associated with the remote connection.
+
---
*** Eshell now uses 'field' properties in its output.
In particular, this means that pressing the '<home>' key moves the
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index 7dcaff1e24f..c7c0a21d2a9 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -163,6 +163,7 @@ if they are quoted with a backslash."
("LINES" ,(lambda () (window-body-height nil 'remap)) t t)
("INSIDE_EMACS" eshell-inside-emacs t)
("UID" ,(lambda () (file-user-uid)) nil t)
+ ("GID" ,(lambda () (file-group-gid)) nil t)
;; for esh-ext.el
("PATH" (,(lambda () (string-join (eshell-get-path t) (path-separator)))
diff --git a/test/lisp/eshell/esh-var-tests.el
b/test/lisp/eshell/esh-var-tests.el
index 771bd5a419c..3e58fe749dd 100644
--- a/test/lisp/eshell/esh-var-tests.el
+++ b/test/lisp/eshell/esh-var-tests.el
@@ -829,6 +829,10 @@ it, since the setter is nil."
"Test that $UID is equivalent to (user-uid) for local directories."
(eshell-command-result-equal "echo $UID" (user-uid)))
+(ert-deftest esh-var-test/gid-var ()
+ "Test that $GID is equivalent to (group-gid) for local directories."
+ (eshell-command-result-equal "echo $GID" (group-gid)))
+
(ert-deftest esh-var-test/last-status-var-lisp-command ()
"Test using the \"last exit status\" ($?) variable with a Lisp command."
(with-temp-eshell
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master e074081af3d: Add special '$GID' variable in Eshell,
Jim Porter <=