From f43da7f0b099eaa8ed96f4e9ac63dc8f0c68fdeb Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Tue, 19 Sep 2023 16:59:11 +0200 Subject: [PATCH] finally fix https://github.com/adoyle-h/bash-completor/discussions/2 by just using the rc-scripts directly --- src/completions.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/completions.sh b/src/completions.sh index 3d536ca..ee64dba 100644 --- a/src/completions.sh +++ b/src/completions.sh @@ -21,14 +21,16 @@ reply_version() { COMPREPLY=( $(compgen -W "${versions[*]}" -- "$cur") ) } -# reply_rcscripts() { -# local jail=${COMP_WORDS[2]} -# local scripts=$(jaildk _get_rc_scripts $jail | sed 's|.*/||') -# scripts=${scripts//$'\n'/ } -# scripts=${scripts//$'\r'/} -# echo "[jail=$jail] [cur=$cur] [scripts=${scripts[*]}]" > debug.log -# COMPREPLY=( $(compgen -W "${scripts[*]}" -- "$cur") ) -# } +# we're taking the easy path here. There might be cases where the +# $name_enable variable doesn't match the actual rc-Script, which +# we will not catch the way we're doing it here, but these are rare +# and the user can specify something manually as well. Also this +# method is way faster than executing rcorder inside the jail +reply_rcscripts() { + local jail=${COMP_WORDS[2]} + local scripts=$(ls $JAILDIR/run/$jail/usr/local/etc/rc.d) + COMPREPLY=( $(compgen -W "${scripts[*]}" -- "$cur") ) +} functions='mount,ports,mtree,pf' modes='start,stop,status,restart' @@ -78,7 +80,7 @@ subcmd_opts_status=(-v) subcmd_args_status=@jail ### sub cmd rc -subcmd_opts_rc=(-m:$modes -r) +subcmd_opts_rc=(-m:$modes -r:@rcscripts) subcmd_args_rc=@jail ### sub cmd ipfw