Skip to contentSkip to conversation

iproute2: bash completion function for tc

PATCH Superseded Quentin Monnet 3 participants 8 messages Apr 26, 2016 – May 3, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi Jamal, Stephen,

I searched for a function providing auto-completion for tc utility in bash, but I found none. So I have created one, and I would like share it with the community. It is available here:
https://github.com/6WIND/tc_bash-completion/blob/master/tc
I would like to make it easily available to tc users, so here is a twofold request:

* I do not know where to submit the code. Should I submit here on netdev for inclusion in iproute2 package, or rather to the bash-completion repository on GitHub? I feel like it would receive better feedback and updates if pushed to iproute2. Could you please provide some advice here?
* The completion for tc seems to work well; I have tested it with many commands, but I am no tc expert, and there are probably some cases where the completion fails to propose the correct choices. I would be really interested in any feedback/bug reports that you, or anyone on this list who uses tc, could provide.

Best regards,
Quentin

#1 lore raw
Quoted 9 lines · Quentin Monnet

Hi Jamal, Stephen,

I searched for a function providing auto-completion for tc utility in bash, but I found none. So I have created one, and I would like share it with the community. It is available here:
https://github.com/6WIND/tc_bash-completion/blob/master/tc
I would like to make it easily available to tc users, so here is a twofold request:

Quoted 9 lines

* I do not know where to submit the code. Should I submit here on netdev for inclusion in iproute2 package, or rather to the bash-completion repository on GitHub? I feel like it would receive better feedback and updates if pushed to iproute2. Could you please provide some advice here?
* The completion for tc seems to work well; I have tested it with many commands, but I am no tc expert, and there are probably some cases where the completion fails to propose the correct choices. I would be really interested in any feedback/bug reports that you, or anyone on this list who uses tc, could provide.

that looks very interesting.
I think making it a part of iproute2 is a good thing. How about installing it into /etc/iproute2/ ? Stephen, any comments?

#2 lore raw
Quoted 20 lines · On Wed, 27 Apr 2016 20:19:26 -0700 Alexei Starovoitov…
Quoted 9 lines · Quentin Monnet

Hi Jamal, Stephen,

I searched for a function providing auto-completion for tc utility in bash, but I found none. So I have created one, and I would like share it with the community. It is available here:
https://github.com/6WIND/tc_bash-completion/blob/master/tc
I would like to make it easily available to tc users, so here is a twofold request:

Quoted 9 lines

* I do not know where to submit the code. Should I submit here on netdev for inclusion in iproute2 package, or rather to the bash-completion repository on GitHub? I feel like it would receive better feedback and updates if pushed to iproute2. Could you please provide some advice here?
* The completion for tc seems to work well; I have tested it with many commands, but I am no tc expert, and there are probably some cases where the completion fails to propose the correct choices. I would be really interested in any feedback/bug reports that you, or anyone on this list who uses tc, could provide.

Quoted 5 lines

that looks very interesting.
I think making it a part of iproute2 is a good thing. How about installing it into /etc/iproute2/ ? Stephen, any comments?

I am ok with keeping it in the repository.
But it would need to be installed in the standard bash directory, is that distro dependent?

#3 lore raw

Hi Alexei, Stephen,

2016-04-27 (22:13 UTC-0700) ~ Stephen Hemminger:

Quoted 29 lines
Quoted 20 lines · On Wed, 27 Apr 2016 20:19:26 -0700 Alexei Starovoitov…
Quoted 9 lines · Quentin Monnet

Hi Jamal, Stephen,

I searched for a function providing auto-completion for tc utility in bash, but I found none. So I have created one, and I would like share it with the community. It is available here:
https://github.com/6WIND/tc_bash-completion/blob/master/tc
I would like to make it easily available to tc users, so here is a twofold request:

Quoted 9 lines

* I do not know where to submit the code. Should I submit here on netdev for inclusion in iproute2 package, or rather to the bash-completion repository on GitHub? I feel like it would receive better feedback and updates if pushed to iproute2. Could you please provide some advice here?
* The completion for tc seems to work well; I have tested it with many commands, but I am no tc expert, and there are probably some cases where the completion fails to propose the correct choices. I would be really interested in any feedback/bug reports that you, or anyone on this list who uses tc, could provide.

Quoted 5 lines

that looks very interesting.
I think making it a part of iproute2 is a good thing. How about installing it into /etc/iproute2/ ? Stephen, any comments?

Quoted 4 lines

I am ok with keeping it in the repository.
But it would need to be installed in the standard bash directory, is that distro dependent?

As far as I know the bash-completion directory is not distro dependent, but it moved at some point (2011) from /etc/bash_completion.d/ to /usr/share/bash-completion/completions/. While backward compatibility is provided with the former location, it is now recommended to use the latter.

So one idea could be to check (in iproute2 Makefile) for existence of /usr/share/bash-completion/completions/ directory, and if not found to fall back to /etc/bash_completion.d/. If none is found, use /usr/share/bash-completion/completions/. Does this seem correct?

#4 lore raw
Quoted 42 lines · Quentin Monnet

Hi Alexei, Stephen,

2016-04-27 (22:13 UTC-0700) ~ Stephen Hemminger:

Quoted 29 lines
Quoted 20 lines · On Wed, 27 Apr 2016 20:19:26 -0700 Alexei Starovoitov…
Quoted 9 lines · Quentin Monnet

Hi Jamal, Stephen,

I searched for a function providing auto-completion for tc utility in bash, but I found none. So I have created one, and I would like share it with the community. It is available here:
https://github.com/6WIND/tc_bash-completion/blob/master/tc
I would like to make it easily available to tc users, so here is a twofold request:

Quoted 9 lines

* I do not know where to submit the code. Should I submit here on netdev for inclusion in iproute2 package, or rather to the bash-completion repository on GitHub? I feel like it would receive better feedback and updates if pushed to iproute2. Could you please provide some advice here?
* The completion for tc seems to work well; I have tested it with many commands, but I am no tc expert, and there are probably some cases where the completion fails to propose the correct choices. I would be really interested in any feedback/bug reports that you, or anyone on this list who uses tc, could provide.

Quoted 5 lines

that looks very interesting.
I think making it a part of iproute2 is a good thing. How about installing it into /etc/iproute2/ ? Stephen, any comments?

Quoted 4 lines

I am ok with keeping it in the repository.
But it would need to be installed in the standard bash directory, is that distro dependent?

As far as I know the bash-completion directory is not distro dependent, but it moved at some point (2011) from /etc/bash_completion.d/ to /usr/share/bash-completion/completions/. While backward compatibility is provided with the former location, it is now recommended to use the latter.

Quoted 4 lines

So one idea could be to check (in iproute2 Makefile) for existence of /usr/share/bash-completion/completions/ directory, and if not found to fall back to /etc/bash_completion.d/. If none is found, use /usr/share/bash-completion/completions/. Does this seem correct?

make sense to me.
For some reason there is also /etc/bash-completion.d/ (note - vs _) and git installs there (which seems to be a bug), but your proposal is good as-is.

#5 lore raw

PATCH 1/1 tc: add bash-completion function

Add function for command completion for tc in bash, and update Makefile to install it:

- Under /usr/share/bash-completion/completions/ (default).
- Or under /etc/bash_completions.d/, which is the old directory for bash-completion, if /usr/share/bash-completion/completions/ is not found AND /etc/bash_completions.d/ exists already.

Inside iproute2 repository, the completion code is in a new bash-completion toplevel directory.

---
 Makefile           |   9 +
 bash-completion/tc | 723 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 732 insertions(+)
 create mode 100644 bash-completion/tc
Makefile +9 -0
index 0190aa004a79..93ce4b430eb2 100644
@@ -7,6 +7,8 @@ DOCDIR?=$(DATADIR)/doc/iproute2
 MANDIR?=$(DATADIR)/man
 ARPDDIR?=/var/lib/arpd
 KERNEL_INCLUDE?=/usr/include
+BASHCOMPDIR?=/usr/share/bash-completion/completions
+OLDBASHCOMPDIR?=/etc/bash_completion.d
 
 # Path to db_185.h include
 DBM_INCLUDE:=$(DESTDIR)/usr/include
@@ -66,6 +68,13 @@ install: all
 		$(DESTDIR)$(DOCDIR)/examples/diffserv
 	@for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
 	install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONFDIR)
+	if [ ! -d $(DESTDIR)$(BASHCOMPDIR) -a -d $(DESTDIR)$(OLDBASHCOMPDIR) ]; then \
+		install -m 0755 -d $(DESTDIR)$(OLDBASHCOMPDIR); \
+		install -m 0644 bash-completion/tc $(DESTDIR)$(OLDBASHCOMPDIR); \
+	else \
+		install -m 0755 -d $(DESTDIR)$(BASHCOMPDIR); \
+		install -m 0644 bash-completion/tc $(DESTDIR)$(BASHCOMPDIR); \
+	fi
 
 snapshot:
 	echo "static const char SNAPSHOT[] = \""`date +%y%m%d`"\";" \
bash-completion/tc new file +723 -0

723 lines not on this page · raw message

Signature · 1 line
2.1.4
#6 lore raw

Re: [PATCH iproute2] tc: add bash-completion function

Quoted 8 lines · On Fri, 29 Apr 2016 10:27:11 +0200 Quentin Monnet <[email protected]>…

Add function for command completion for tc in bash, and update Makefile to install it:

- Under /usr/share/bash-completion/completions/ (default).
- Or under /etc/bash_completions.d/, which is the old directory for bash-completion, if /usr/share/bash-completion/completions/ is not found AND /etc/bash_completions.d/ exists already.

Quoted 4 lines

Inside iproute2 repository, the completion code is in a new bash-completion toplevel directory.

Rather than having an if statement in the install; lets follow how other paths are handles.
* default value should be what current distros use /usr/share
* other distro's can override it with environment variable.

Something like:

Makefile:
PREFIX?=/usr
LIBDIR?=$(PREFIX)/lib
SBINDIR?=/sbin
CONFDIR?=/etc/iproute2 DATADIR?=$(PREFIX)/share DOCDIR?=$(DATADIR)/doc/iproute2 MANDIR?=$(DATADIR)/man
ARPDDIR?=/var/lib/arpd KERNEL_INCLUDE?=/usr/include BASH_COMPDIR?=$(DATADIR)/bash-completion/completions/

#7 lore raw

PATCH v2 1/1 tc: add bash-completion function

Add function for command completion for tc in bash, and update Makefile to install it under /usr/share/bash-completion/completions/.

Inside iproute2 repository, the completion code is in a new bash-completion toplevel directory.

v2: Remove if statement in Makefile: do not try to install in
/etc/bash_completion.d/ if /usr/share/bash-completion/completions/ is not found; instead, the user can override the installation path with the specific environment variable.

---
 Makefile           |   3 +
 bash-completion/tc | 723 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 726 insertions(+)
 create mode 100644 bash-completion/tc
Makefile +3 -0
index 0190aa004a79..eb571a5accf8 100644
@@ -7,6 +7,7 @@ DOCDIR?=$(DATADIR)/doc/iproute2
 MANDIR?=$(DATADIR)/man
 ARPDDIR?=/var/lib/arpd
 KERNEL_INCLUDE?=/usr/include
+BASH_COMPDIR?=$(DATADIR)/bash-completion/completions
 
 # Path to db_185.h include
 DBM_INCLUDE:=$(DESTDIR)/usr/include
@@ -66,6 +67,8 @@ install: all
 		$(DESTDIR)$(DOCDIR)/examples/diffserv
 	@for i in $(SUBDIRS) doc; do $(MAKE) -C $$i install; done
 	install -m 0644 $(shell find etc/iproute2 -maxdepth 1 -type f) $(DESTDIR)$(CONFDIR)
+	install -m 0755 -d $(DESTDIR)$(BASH_COMPDIR)
+	install -m 0644 bash-completion/tc $(DESTDIR)$(BASH_COMPDIR)
 
 snapshot:
 	echo "static const char SNAPSHOT[] = \""`date +%y%m%d`"\";" \
bash-completion/tc new file +723 -0

723 lines not on this page · raw message

Signature · 1 line
2.1.4