finally fix https://github.com/adoyle-h/bash-completor/discussions/2 by just using the rc-scripts directly

This commit is contained in:
Thomas von Dein
2023-09-19 16:59:11 +02:00
parent cbac202c38
commit f43da7f0b0

View File

@@ -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