AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
[AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
AC_MSG_RESULT([$with_systemdsystemunitdir])
+
+AC_MSG_CHECKING([bash-completion directory])
+AC_ARG_WITH([bash-completion-dir],
+ AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
+ [Install the bash auto-completion script in this directory.]),
+ [],
+ [with_bash_completion_dir=yes])
+AS_IF([test "x$with_bash_completion_dir" = "xyes"], [
+ BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"
+ AS_IF([test "x$BASH_COMPLETION_DIR" = "x"], [
+ [BASH_COMPLETION_DIR="$datadir/bash-completion/completions"]
+ ])
+], [
+ BASH_COMPLETION_DIR="$with_bash_completion_dir"
+])
+AC_SUBST([BASH_COMPLETION_DIR])
+AC_MSG_RESULT([$BASH_COMPLETION_DIR])
]) # LC_CONFIGURE
#
AM_CONDITIONAL(GSS_SSK, test x$enable_ssk = xyes)
AM_CONDITIONAL(LIBPTHREAD, test x$enable_libpthread = xyes)
AM_CONDITIONAL(HAVE_SYSTEMD, test "x$with_systemdsystemunitdir" != "xno")
+AM_CONDITIONAL(ENABLE_BASH_COMPLETION, test "x$with_bash_completion_dir" != "xno")
AM_CONDITIONAL(XATTR_HANDLER, test "x$lb_cv_compile_xattr_handler_flags" = xyes)
AM_CONDITIONAL(SELINUX, test "$SELINUX" = "-lselinux")
AM_CONDITIONAL(GETSEPOL, test x$enable_getsepol = xyes)
endif # UTILS
+if ENABLE_BASH_COMPLETION
+bashcompletiondir = $(BASH_COMPLETION_DIR)
+dist_bashcompletion_DATA = bash-completion/lctl
+endif
+
EXTRA_DIST = license-status lustre_rmmod ldev lc_mon lhbadm \
lc_servip lustre_routes_config lustre_routes_conversion \
$(addsuffix .in,$(genscripts)) lfs_migrate lustre_req_history \
lustre lsvcgss lc_common haconfig Lustre.ha_v2 dkms.mkconf \
- zfsobj2fid ko2iblnd-probe statechange-lustre.sh
+ zfsobj2fid ko2iblnd-probe statechange-lustre.sh \
+ bash-completion/lctl
CLEANFILES = $(genscripts)
--- /dev/null
+_lctl()
+{
+ local cur prev words cword
+
+ _init_completion || return
+ COMPREPLY=()
+
+ if [[ "$cword" == "1" ]]; then
+ COMPREPLY=( $( compgen -W '$(lctl --list-commands |
+ grep -v '^=')' -- "$cur" ) )
+ return 0
+ fi
+
+ case "${words[1]}" in
+ set_param|list_param|get_param)
+ local filter="s/=$//"
+ [[ "${words[1]}" == "set_param" ]] && filter="/[^=/]$/d"
+ mapfile -t COMPREPLY < <(
+ lctl list_param -F "${cur#[\"\']}*" 2>/dev/null |
+ sed -e "$filter" -e 's#/$#.#' \
+ -e "s#^${cur//\*/[^.]*}#$cur#"
+ )
+ compopt -o nospace
+
+ return 0
+ ;;
+ esac
+} &&
+complete -F _lctl lctl