emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#22091: closed ([PATCH 1/2] * lisp/env.el: Add (whe


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#22091: closed ([PATCH 1/2] * lisp/env.el: Add (whereis-command))
Date: Sat, 05 Dec 2015 00:54:02 +0000

Your message dated Fri, 04 Dec 2015 19:53:34 -0500
with message-id <address@hidden>
and subject line Re: bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command)
has caused the debbugs.gnu.org bug report #22091,
regarding [PATCH 1/2] * lisp/env.el: Add (whereis-command)
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
22091: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22091
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH 1/2] * lisp/env.el: Add (whereis-command) Date: Fri, 4 Dec 2015 14:25:12 +0800
---
 lisp/env.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lisp/env.el b/lisp/env.el
index 3966ab1..a16f534 100644
--- a/lisp/env.el
+++ b/lisp/env.el
@@ -218,6 +218,13 @@ in the environment list of the selected frame."
       (message "%s" (if value value "Not set")))
     value))
 
+(defun whereis-command (command)
+  (let ((paths (split-string (getenv "PATH") ":")))
+    (remove-if-not
+     (lambda (path)
+       (file-exists-p (format "%s/%s" path command)))
+     paths)))
+
 (provide 'env)
 
 ;;; env.el ends here
-- 
2.5.0






--- End Message ---
--- Begin Message --- Subject: Re: bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command) Date: Fri, 04 Dec 2015 19:53:34 -0500 User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
Version: 25.1

Thanks for the report and the patch(es).
I installed something slightly different into emacs-25, to take care of
a few other related bits at the same time:

--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -35,15 +35,19 @@
 ;; * Support connections to HOST/PORT, generally for debugging and the like.
 ;; In other words, for doing much the same thing as "telnet HOST PORT", and
 ;; then typing commands.
-;;
-;; PATHS
-;;
-;; On some systems, some of these programs are not in normal user path,
-;; but rather in /sbin, /usr/sbin, and so on.
-
 
 ;;; Code:
 
+;; On some systems, programs like ifconfig are not in normal user
+;; path, but rather in /sbin, /usr/sbin, etc (but non-root users can
+;; still use them for queries).  Actually the trend these
+;; day is for /sbin to be a symlink to /usr/sbin, but we still need to
+;; search both for older systems.
+(defun net-utils--executable-find-sbin (command)
+  "Return absolute name of COMMAND if found in an sbin directory."
+  (let ((exec-path '("/sbin" "/usr/sbin" "/usr/local/sbin")))
+    (executable-find command)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Customization Variables
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -85,10 +89,13 @@ These options can be used to limit how many ICMP packets 
are emitted."
 (define-obsolete-variable-alias 'ipconfig-program 'ifconfig-program "22.2")
 
 (defcustom ifconfig-program
-  (if (eq system-type 'windows-nt)
-      "ipconfig"
-    "ifconfig")
+  (cond ((eq system-type 'windows-nt) "ipconfig")
+        ((executable-find "ifconfig") "ifconfig")
+        ((net-utils--executable-find-sbin "ifconfig"))
+        ((net-utils--executable-find-sbin "ip"))
+        (t "ip"))
   "Program to print network configuration information."
+  :version "25.1"                       ; add ip
   :group 'net-utils
   :type  'string)
 
@@ -96,10 +103,12 @@ These options can be used to limit how many ICMP packets 
are emitted."
   'ifconfig-program-options "22.2")
 
 (defcustom ifconfig-program-options
-  (list
-   (if (eq system-type 'windows-nt)
-       "/all" "-a"))
+  (cond ((string-match "ipconfig\\'" ifconfig-program) '("/all"))
+        ((string-match "ifconfig\\'" ifconfig-program) '("-a"))
+        ((string-match "ip\\'" ifconfig-program) '("addr")))
   "Options for the ifconfig program."
+  :version "25.1"
+  :set-after '(ifconfig-program)
   :group 'net-utils
   :type  '(repeat string))
 
@@ -126,7 +135,7 @@ These options can be used to limit how many ICMP packets 
are emitted."
   :group 'net-utils
   :type  '(repeat string))
 
-(defcustom arp-program "arp"
+(defcustom arp-program (or (net-utils--executable-find-sbin "arp") "arp")
   "Program to print IP to address translation tables."
   :group 'net-utils
   :type  'string)


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]