unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#64529: 30.0.50; [PATCH] Add special $GID variable for Eshell
@ 2023-07-08  6:35 Jim Porter
  2023-07-08 13:07 ` Michael Albinus
  0 siblings, 1 reply; 6+ messages in thread
From: Jim Porter @ 2023-07-08  6:35 UTC (permalink / raw)
  To: 64529

[-- Attachment #1: Type: text/plain, Size: 204 bytes --]

Currently, Eshell has a special $UID variable that's connection-aware 
(so it returns the remote UID if the current directory is remote). 
However, it doesn't do this for $GID. Here's a patch to fix that.

[-- Attachment #2: 0001-Add-special-GID-variable-in-Eshell.patch --]
[-- Type: text/plain, Size: 2423 bytes --]

From d5f4f5a944cb60f9068976d1d91e981d21c79cb2 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Fri, 7 Jul 2023 23:18:33 -0700
Subject: [PATCH] Add special '$GID' variable in Eshell

* 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'.
---
 doc/misc/eshell.texi              | 7 +++++++
 lisp/eshell/esh-var.el            | 1 +
 test/lisp/eshell/esh-var-tests.el | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi
index 5972d2834b0..a1f541da9da 100644
--- a/doc/misc/eshell.texi
+++ b/doc/misc/eshell.texi
@@ -993,6 +993,13 @@ Variables
 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/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 @@ eshell-variable-aliases-list
     ("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 @@ esh-var-test/uid-var
   "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
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#64529: 30.0.50; [PATCH] Add special $GID variable for Eshell
  2023-07-08  6:35 bug#64529: 30.0.50; [PATCH] Add special $GID variable for Eshell Jim Porter
@ 2023-07-08 13:07 ` Michael Albinus
  2023-07-08 19:27   ` Jim Porter
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2023-07-08 13:07 UTC (permalink / raw)
  To: Jim Porter; +Cc: 64529

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

> Currently, Eshell has a special $UID variable that's connection-aware
> (so it returns the remote UID if the current directory is
> remote). However, it doesn't do this for $GID. Here's a patch to fix
> that.

LGTM.

Best regards, Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#64529: 30.0.50; [PATCH] Add special $GID variable for Eshell
  2023-07-08 13:07 ` Michael Albinus
@ 2023-07-08 19:27   ` Jim Porter
  2023-07-09  8:43     ` Michael Albinus
  0 siblings, 1 reply; 6+ messages in thread
From: Jim Porter @ 2023-07-08 19:27 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 64529-done

On 7/8/2023 6:07 AM, Michael Albinus wrote:
> LGTM.

Thanks for taking a look. Merged as e074081af3d, and closing this now.






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#64529: 30.0.50; [PATCH] Add special $GID variable for Eshell
  2023-07-08 19:27   ` Jim Porter
@ 2023-07-09  8:43     ` Michael Albinus
  2023-07-09 19:31       ` Jim Porter
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2023-07-09  8:43 UTC (permalink / raw)
  To: Jim Porter; +Cc: 64529

Jim Porter <jporterbugs@gmail.com> writes:

> Thanks for taking a look. Merged as e074081af3d, and closing this now.

Thanks. Just a minor comment: you might document, that $UID and $GID
return -1 in case they cannot determine the value on a remote system.

But maybe this is too minor to be mentioned in the Eshell manual, so
it's just your decision.

Best regards, Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#64529: 30.0.50; [PATCH] Add special $GID variable for Eshell
  2023-07-09  8:43     ` Michael Albinus
@ 2023-07-09 19:31       ` Jim Porter
  2023-07-09 20:04         ` Michael Albinus
  0 siblings, 1 reply; 6+ messages in thread
From: Jim Porter @ 2023-07-09 19:31 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 64529

On 7/9/2023 1:43 AM, Michael Albinus wrote:
> Thanks. Just a minor comment: you might document, that $UID and $GID
> return -1 in case they cannot determine the value on a remote system.
> 
> But maybe this is too minor to be mentioned in the Eshell manual, so
> it's just your decision.

I thought about that too, but decided it was a bit too minor. I could be 
convinced otherwise though; I don't have a strong feeling about it.






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#64529: 30.0.50; [PATCH] Add special $GID variable for Eshell
  2023-07-09 19:31       ` Jim Porter
@ 2023-07-09 20:04         ` Michael Albinus
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Albinus @ 2023-07-09 20:04 UTC (permalink / raw)
  To: Jim Porter; +Cc: 64529

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

>> Thanks. Just a minor comment: you might document, that $UID and $GID
>> return -1 in case they cannot determine the value on a remote system.
>> But maybe this is too minor to be mentioned in the Eshell manual, so
>> it's just your decision.
>
> I thought about that too, but decided it was a bit too minor. I could
> be convinced otherwise though; I don't have a strong feeling about it.

As said, your decision. I have also no strong position about.

Best regards, Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-09 20:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-08  6:35 bug#64529: 30.0.50; [PATCH] Add special $GID variable for Eshell Jim Porter
2023-07-08 13:07 ` Michael Albinus
2023-07-08 19:27   ` Jim Porter
2023-07-09  8:43     ` Michael Albinus
2023-07-09 19:31       ` Jim Porter
2023-07-09 20:04         ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).