Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 360083 - app-shells/bash-completion doesn't auto complete "sudo /etc/init.d/xxx" correctly
Summary: app-shells/bash-completion doesn't auto complete "sudo /etc/init.d/xxx" corre...
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Shell Tools project
URL: https://alioth.debian.org/tracker/ind...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-23 07:53 UTC by James
Modified: 2017-07-02 22:32 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James 2011-03-23 07:53:36 UTC
it works without sudo.

Reproducible: Always

Steps to Reproduce:
1. sudo /etc/init.d/sshd <TAB><TAB>
2.
3.
Actual Results:  
local files are listed

Expected Results:  
prompt possible operations(eg. start, stop, etc.)
Comment 1 James 2011-03-23 07:59:53 UTC
(In reply to comment #0)
> it works without sudo.
> 
> Reproducible: Always
> 
> Steps to Reproduce:
> 1. sudo /etc/init.d/sshd <TAB><TAB>
> 2.
> 3.
> Actual Results:  
> local files are listed
> 
> Expected Results:  
> prompt possible operations(eg. start, stop, etc.)

forgot to mention, I am using bash-completion-1.3
Comment 2 SpanKY gentoo-dev 2011-03-27 14:12:07 UTC
always post `emerge --info` with your bug reports
Comment 3 James 2011-03-27 14:17:27 UTC
james@localhost ~ $ emerge --info
Portage 2.2.2 (default/linux/amd64/2008.0/desktop, gcc-4.4.5, glibc-2.11.2-r2, 2.6.38-gentoo x86_64)
=================================================================
System uname: Linux-2.6.38-gentoo-x86_64-Intel-R-_Core-TM-2_Duo_CPU_T7300_@_2.00GHz-with-gentoo-2.1.8
Portage Tree: /usr/portage
Portage HEAD: a6bffaa5f22ca29d44c998a8a45b2313ad2fbffa /usr/portage/.git/refs/heads/funtoo.org
ccache version 3.1.4 [enabled]
app-shells/bash:     4.1_p10
dev-java/java-config: 2.1.11-r3::funtoo
dev-lang/python:     2.6.6-r1
dev-util/ccache:     3.1.4
dev-util/cmake:      2.8.4
sys-apps/baselayout: 2.1.8-r2::funtoo
sys-apps/openrc:     0.7.0
sys-apps/sandbox:    2.5
sys-devel/autoconf:  2.13::funtoo, 2.68::funtoo
sys-devel/automake:  1.8.5-r4, 1.9.6-r3::funtoo, 1.10.3::funtoo, 1.11.1::funtoo
sys-devel/binutils:  2.20.1::funtoo
sys-devel/gcc:       4.3.3-r2::funtoo, 4.4.5::funtoo
sys-devel/gcc-config: 1.4.1::funtoo
sys-devel/libtool:   2.4-r1
sys-devel/make:      3.81-r2::funtoo
virtual/os-headers:  2.6.32::funtoo (sys-kernel/linux-headers)
Repositories: gentoo gentoo-china gnome sunrise mozilla oss-overlay jamesjjx-repo
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=core2 -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.3/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cli-php5.3/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/splash /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs ccache collision-protect distlocks fixlafiles fixpackages mini-manifest news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://ftp.twaren.net/Linux/Gentoo/ http://ftp.cs.pu.edu.tw/Linux/Gentoo/ ftp://ftp.twaren.net/Linux/Gentoo/"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed"
LINGUAS="en_US"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/gentoo-china /var/lib/layman/gnome /var/lib/layman/sunrise /var/lib/layman/mozilla /var/lib/layman/oss-overlay /usr/local/portage/jamesjjx"
SYNC="git://github.com/funtoo/portage-mini-2010.git"
SYNC_USER="root"
USE="X a52 aac acl acpi alac alsa amd64 asf bash-completion berkdb branding bzip2 cairo cdr cleartype cli consolekit cracklib crypt cups cxx dbus dri dts dvd dvdr dvdread emboss encode esd exif fam fbcondecor firefox flac fortran gdbm gdu gif glitz gnome gnome-keyring gpm gtk hdaps iconv ipv6 jpeg kpathsea lame lcms ldap libnotify mad mikmod mmx mng modules mp3 mp4 mpeg mudflap multilib ncurses nls nptl nptlonly nsplugin nvidia ogg opengl openmp pam pango pcre pdf perl png policykit ppds pppd python qt3support readline sdl session spell sse sse2 ssl startup-notification svg symlink sysfs tcpd tiff truetype udev unicode usb vdpau vim-syntax vorbis wavpack x264 xcb xcomposite xinerama xml xorg xulrunner xv xvid xvmc zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="synaptics evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en_US" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, SYNC_UMASK
Comment 4 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2011-03-27 19:10:25 UTC
It is actually a problem with app-shells/gentoo-bashcomp.

*** This bug has been marked as a duplicate of bug 336081 ***
Comment 5 James 2011-03-28 07:22:14 UTC
I don't think they are the same...
I looked into it a little bit.
The problem is that when you type "sudo cmd <TAB>", bash-completion will run "complete -p ${cmd##*/}" to get the completion information.
So when typing "sudo /etc/init.d/XXX", it prompts with the options for the command "XXX" instead of "/etc/init.d/XXX".

James
Comment 6 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2011-03-30 02:41:12 UTC
(In reply to comment #5)
> I don't think they are the same...
> I looked into it a little bit.
> The problem is that when you type "sudo cmd <TAB>", bash-completion will run
> "complete -p ${cmd##*/}" to get the completion information.
> So when typing "sudo /etc/init.d/XXX", it prompts with the options for the
> command "XXX" instead of "/etc/init.d/XXX".
> 
> James

You might be right. Mind trying bash-completion-1.2 and finding out what the problem is?
Comment 7 James 2011-03-30 14:26:25 UTC
Aha, bash-completion-1.2 works.
I will stick to 1.2 for a while then.

I guess the developers switched from "complete -p $cmd"(1.2) to "complete -p ${cmd##*/}"(1.3) to handle the cases like "/bin/xxx <TAB>".
One easy fix may be running "complete -p $cmd" first and running "complete -p ${cmd##*/}" one more time in case the first checking fails.

James
Comment 8 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2011-03-30 14:52:58 UTC
Thanks for the analysis, could you open a bug report upstream and see what they have to say? Please add the link here. bash-completion-1.2 will be removed from gentoo soon.
Comment 10 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2011-03-30 20:11:04 UTC
thx
Comment 11 James 2011-04-12 18:21:28 UTC
It has been fixed upstream in the git tree.

James
Comment 12 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-07-02 22:32:21 UTC
I don't think /etc/init.d/* completion is going to work at all with the modern bash-completion versions.