diff --git a/contrib/bash_completion.d/.gitignore b/contrib/bash_completion.d/.gitignore new file mode 100644 index 0000000000..0fd9cc63af --- /dev/null +++ b/contrib/bash_completion.d/.gitignore @@ -0,0 +1 @@ +/zfs diff --git a/contrib/bash_completion.d/Makefile.am b/contrib/bash_completion.d/Makefile.am index 4f13af6b3c..8fbe03688b 100644 --- a/contrib/bash_completion.d/Makefile.am +++ b/contrib/bash_completion.d/Makefile.am @@ -1,5 +1,8 @@ +include $(top_srcdir)/config/Substfiles.am + bashcompletiondir = $(sysconfdir)/bash_completion.d noinst_DATA = zfs -EXTRA_DIST = $(noinst_DATA) +EXTRA_DIST += $(noinst_DATA) +SUBSTFILES += $(noinst_DATA) diff --git a/contrib/bash_completion.d/zfs b/contrib/bash_completion.d/zfs.in similarity index 98% rename from contrib/bash_completion.d/zfs rename to contrib/bash_completion.d/zfs.in index 094527340c..8898fc735c 100644 --- a/contrib/bash_completion.d/zfs +++ b/contrib/bash_completion.d/zfs.in @@ -21,13 +21,8 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -if [[ -w /dev/zfs ]]; then - __ZFS_CMD="zfs" - __ZPOOL_CMD="zpool" -else - __ZFS_CMD="sudo zfs" - __ZPOOL_CMD="sudo zpool" -fi +__ZFS_CMD="@sbindir@/zfs" +__ZPOOL_CMD="@sbindir@/zpool" # Disable bash's built-in hostname completion, as this makes it impossible to # provide completions containing an @-sign, which is necessary for completing @@ -198,7 +193,7 @@ __zfs_complete_multiple_options() COMPREPLY=($(compgen -W "$options" -- "${cur##*,}")) local existing_opts=$(expr "$cur" : '\(.*,\)') - if [[ $existing_opts ]] + if [[ $existing_opts ]] then COMPREPLY=( "${COMPREPLY[@]/#/${existing_opts}}" ) fi