diff options
| author | Jim Porter | 2023-07-07 23:18:33 -0700 |
|---|---|---|
| committer | Jim Porter | 2023-07-08 12:19:29 -0700 |
| commit | e074081af3de6bbdff330f6fa60355b3a86215bb (patch) | |
| tree | 5ae04f3f91038dc07914bccb920a481d0ebb11e5 | |
| parent | 8c5fef4eb301d878b9761ebf74f845895f014610 (diff) | |
| download | emacs-e074081af3de6bbdff330f6fa60355b3a86215bb.tar.gz emacs-e074081af3de6bbdff330f6fa60355b3a86215bb.zip | |
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').
| -rw-r--r-- | doc/misc/eshell.texi | 7 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/eshell/esh-var.el | 1 | ||||
| -rw-r--r-- | test/lisp/eshell/esh-var-tests.el | 4 |
4 files changed, 17 insertions, 0 deletions
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, | |||
| 993 | its value will be @acronym{UID} for the user associated with that | 993 | its value will be @acronym{UID} for the user associated with that |
| 994 | remote connection. | 994 | remote connection. |
| 995 | 995 | ||
| 996 | @vindex $GID | ||
| 997 | @item $GID | ||
| 998 | This returns the effective @acronym{GID} for the current user. Like | ||
| 999 | @code{$UID}, this variable is connection-aware, so when the current | ||
| 1000 | directory is remote, its value will be @acronym{GID} for the user | ||
| 1001 | associated with that remote connection. | ||
| 1002 | |||
| 996 | @vindex $_ | 1003 | @vindex $_ |
| 997 | @item $_ | 1004 | @item $_ |
| 998 | This refers to the last argument of the last command. With a | 1005 | This refers to the last argument of the last command. With a |
| @@ -202,6 +202,11 @@ or get a sublist of elements 2 through 4 with '$my-list[2..5]'. For | |||
| 202 | more information, see the "(eshell) Dollars Expansion" node in the | 202 | more information, see the "(eshell) Dollars Expansion" node in the |
| 203 | Eshell manual. | 203 | Eshell manual. |
| 204 | 204 | ||
| 205 | +++ | ||
| 206 | *** Eshell's '$UID' and '$GID' variables are now connection-aware. | ||
| 207 | Now, when expanding '$UID' or '$GID' in a remote directory, the value | ||
| 208 | is the user or group ID associated with the remote connection. | ||
| 209 | |||
| 205 | --- | 210 | --- |
| 206 | *** Eshell now uses 'field' properties in its output. | 211 | *** Eshell now uses 'field' properties in its output. |
| 207 | In particular, this means that pressing the '<home>' key moves the | 212 | 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." | |||
| 163 | ("LINES" ,(lambda () (window-body-height nil 'remap)) t t) | 163 | ("LINES" ,(lambda () (window-body-height nil 'remap)) t t) |
| 164 | ("INSIDE_EMACS" eshell-inside-emacs t) | 164 | ("INSIDE_EMACS" eshell-inside-emacs t) |
| 165 | ("UID" ,(lambda () (file-user-uid)) nil t) | 165 | ("UID" ,(lambda () (file-user-uid)) nil t) |
| 166 | ("GID" ,(lambda () (file-group-gid)) nil t) | ||
| 166 | 167 | ||
| 167 | ;; for esh-ext.el | 168 | ;; for esh-ext.el |
| 168 | ("PATH" (,(lambda () (string-join (eshell-get-path t) (path-separator))) | 169 | ("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." | |||
| 829 | "Test that $UID is equivalent to (user-uid) for local directories." | 829 | "Test that $UID is equivalent to (user-uid) for local directories." |
| 830 | (eshell-command-result-equal "echo $UID" (user-uid))) | 830 | (eshell-command-result-equal "echo $UID" (user-uid))) |
| 831 | 831 | ||
| 832 | (ert-deftest esh-var-test/gid-var () | ||
| 833 | "Test that $GID is equivalent to (group-gid) for local directories." | ||
| 834 | (eshell-command-result-equal "echo $GID" (group-gid))) | ||
| 835 | |||
| 832 | (ert-deftest esh-var-test/last-status-var-lisp-command () | 836 | (ert-deftest esh-var-test/last-status-var-lisp-command () |
| 833 | "Test using the \"last exit status\" ($?) variable with a Lisp command." | 837 | "Test using the \"last exit status\" ($?) variable with a Lisp command." |
| 834 | (with-temp-eshell | 838 | (with-temp-eshell |