* bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command)
@ 2015-12-04 6:25 lu4nx
2015-12-04 6:25 ` bug#22091: [PATCH 2/2] * lisp/net/net-utils.el: (ifconfig) function support `ip` command lu4nx
2015-12-04 8:03 ` bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command) Glenn Morris
0 siblings, 2 replies; 5+ messages in thread
From: lu4nx @ 2015-12-04 6:25 UTC (permalink / raw)
To: 22091; +Cc: lu4nx
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#22091: [PATCH 2/2] * lisp/net/net-utils.el: (ifconfig) function support `ip` command.
2015-12-04 6:25 bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command) lu4nx
@ 2015-12-04 6:25 ` lu4nx
2015-12-04 8:03 ` bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command) Glenn Morris
1 sibling, 0 replies; 5+ messages in thread
From: lu4nx @ 2015-12-04 6:25 UTC (permalink / raw)
To: 22091; +Cc: lu4nx
In some Linux distribution default not found `ifconfig` command, such as CentOS7.
- `ifconfig-program` and `ifconfig-program-options` add support `ip` command.
---
lisp/net/net-utils.el | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index c6d40b6..74e832a 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -87,7 +87,9 @@ These options can be used to limit how many ICMP packets are emitted."
(defcustom ifconfig-program
(if (eq system-type 'windows-nt)
"ipconfig"
- "ifconfig")
+ (if (whereis-command "ifconfig")
+ "ifconfig"
+ "ip"))
"Program to print network configuration information."
:group 'net-utils
:type 'string)
@@ -97,8 +99,10 @@ These options can be used to limit how many ICMP packets are emitted."
(defcustom ifconfig-program-options
(list
- (if (eq system-type 'windows-nt)
- "/all" "-a"))
+ (cond ((eq system-type 'windows-nt) "/all")
+ ((and (whereis-command "ip")
+ (not (whereis-command "ifconfig"))) "addr")
+ (t "-a")))
"Options for the ifconfig program."
:group 'net-utils
:type '(repeat string))
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command)
2015-12-04 6:25 bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command) lu4nx
2015-12-04 6:25 ` bug#22091: [PATCH 2/2] * lisp/net/net-utils.el: (ifconfig) function support `ip` command lu4nx
@ 2015-12-04 8:03 ` Glenn Morris
2015-12-04 8:17 ` bug#22091: �ظ���bug#22091: " lux
1 sibling, 1 reply; 5+ messages in thread
From: Glenn Morris @ 2015-12-04 8:03 UTC (permalink / raw)
To: lu4nx; +Cc: 22091
lu4nx wrote:
> +(defun whereis-command (command)
> + (let ((paths (split-string (getenv "PATH") ":")))
> + (remove-if-not
> + (lambda (path)
> + (file-exists-p (format "%s/%s" path command)))
> + paths)))
You use a CL function without requiring CL.
But 'executable-find' already exists anyway, so this isn't needed.
Also, you sent 4 or 5 identical copies of each of your mails in rapid
succession (filtered out by list moderation). Please fix your mailer.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#22091: �ظ���bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command)
2015-12-04 8:03 ` bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command) Glenn Morris
@ 2015-12-04 8:17 ` lux
2015-12-05 0:53 ` bug#22091: " Glenn Morris
0 siblings, 1 reply; 5+ messages in thread
From: lux @ 2015-12-04 8:17 UTC (permalink / raw)
To: Glenn Morris; +Cc: 22091
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1: Type: text/plain; charset="gb18030", Size: 1835 bytes --]
I'm sorry, his is new patch, thank you Glenn Morris:
diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index c6d40b6..0a4693f 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -87,7 +87,9 @@ These options can be used to limit how many ICMP packets are emitted."
(defcustom ifconfig-program
(if (eq system-type 'windows-nt)
"ipconfig"
- "ifconfig")
+ (if (executable-find "ifconfig")
+ "ifconfig"
+ "ip"))
"Program to print network configuration information."
:group 'net-utils
:type 'string)
@@ -97,8 +99,10 @@ These options can be used to limit how many ICMP packets are emitted."
(defcustom ifconfig-program-options
(list
- (if (eq system-type 'windows-nt)
- "/all" "-a"))
+ (cond ((eq system-type 'windows-nt) "/all")
+ ((and (executable-find "ip")
+ (not (executable-find "ifconfig"))) "addr")
+ (t "-a")))
"Options for the ifconfig program."
:group 'net-utils
:type '(repeat string))
--
2.5.0
------------------ ÔʼÓʼþ ------------------
·¢¼þÈË: "Glenn Morris";<rgm@gnu.org>;
·¢ËÍʱ¼ä: 2015Äê12ÔÂ4ÈÕ(ÐÇÆÚÎå) ÏÂÎç4:03
ÊÕ¼þÈË: "lux"<lx@shellcodes.org>;
³ËÍ: "22091"<22091@debbugs.gnu.org>;
Ö÷Ìâ: bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command)
lu4nx wrote:
> +(defun whereis-command (command)
> + (let ((paths (split-string (getenv "PATH") ":")))
> + (remove-if-not
> + (lambda (path)
> + (file-exists-p (format "%s/%s" path command)))
> + paths)))
You use a CL function without requiring CL.
But 'executable-find' already exists anyway, so this isn't needed.
Also, you sent 4 or 5 identical copies of each of your mails in rapid
succession (filtered out by list moderation). Please fix your mailer.
[-- Attachment #1.2: Type: text/html, Size: 3017 bytes --]
[-- Attachment #2: 0001-lisp-net-net-utils.el-ifconfig-function-support-ip.patch --]
[-- Type: application/octet-stream, Size: 1437 bytes --]
From 27b9af13c9662abad4a252b0e28bb5d40ef4e9ea Mon Sep 17 00:00:00 2001
From: lu4nx <lx@shellcodes.org>
Date: Fri, 4 Dec 2015 16:13:31 +0800
Subject: [PATCH] * lisp/net/net-utils.el: (ifconfig) function support `ip`
In some Linux distribution default not found `ifconfig` command, such as CentOS7.
- `ifconfig-program` and `ifconfig-program-options` add support `ip` command.
---
lisp/net/net-utils.el | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index c6d40b6..0a4693f 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -87,7 +87,9 @@ These options can be used to limit how many ICMP packets are emitted."
(defcustom ifconfig-program
(if (eq system-type 'windows-nt)
"ipconfig"
- "ifconfig")
+ (if (executable-find "ifconfig")
+ "ifconfig"
+ "ip"))
"Program to print network configuration information."
:group 'net-utils
:type 'string)
@@ -97,8 +99,10 @@ These options can be used to limit how many ICMP packets are emitted."
(defcustom ifconfig-program-options
(list
- (if (eq system-type 'windows-nt)
- "/all" "-a"))
+ (cond ((eq system-type 'windows-nt) "/all")
+ ((and (executable-find "ip")
+ (not (executable-find "ifconfig"))) "addr")
+ (t "-a")))
"Options for the ifconfig program."
:group 'net-utils
:type '(repeat string))
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command)
2015-12-04 8:17 ` bug#22091: �ظ���bug#22091: " lux
@ 2015-12-05 0:53 ` Glenn Morris
0 siblings, 0 replies; 5+ messages in thread
From: Glenn Morris @ 2015-12-05 0:53 UTC (permalink / raw)
To: 22091-done
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)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-12-05 0:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-04 6:25 bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command) lu4nx
2015-12-04 6:25 ` bug#22091: [PATCH 2/2] * lisp/net/net-utils.el: (ifconfig) function support `ip` command lu4nx
2015-12-04 8:03 ` bug#22091: [PATCH 1/2] * lisp/env.el: Add (whereis-command) Glenn Morris
2015-12-04 8:17 ` bug#22091: �ظ���bug#22091: " lux
2015-12-05 0:53 ` bug#22091: " Glenn Morris
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).