慕仔1275163
2017-04-25 11:25
cmdOpts=${cmdOpts/ --no-newline / }
;;
--no-newline)
cmdOpts=${cmdOpts/ -n / }
;;
-h)
cmdOpts=${cmdOpts/ --help / }
;;
--help)
cmdOpts=${cmdOpts/ -h / }
;;
-c)
cmdOpts=${cmdOpts/ --committed / }
;;
--committed)
cmdOpts=${cmdOpts/ -c / }
;;
esac;
done;
COMPREPLY=($( compgen -W "$cmdOpts" -- $cur ));
return 0
}
_sysvdirs ()
{
sysvdirs=();
[[ -d /etc/rc.d/init.d ]] && sysvdirs+=(/etc/rc.d/init.d);
[[ -d /etc/init.d ]] && sysvdirs+=(/etc/init.d);
[[ -f /etc/slackware-version ]] && sysvdirs=(/etc/rc.d)
}
_terms ()
{
COMPREPLY+=($( compgen -W "$( sed -ne 's/^\([^[:space:]#|]\{2,\}\)|.*/\1/p' /etc/termcap 2>/dev/null )" -- "$cur" ));
COMPREPLY+=($( compgen -W "$( { toe -a 2>/dev/null || toe 2>/dev/null; } | awk '{ print $1 }' | sort -u )" -- "$cur" ))
}
_tilde ()
{
local result=0;
if [[ $1 == \~* && $1 != */* ]]; then
COMPREPLY=($( compgen -P '~' -u "${1#\~}" ));
result=${#COMPREPLY[@]};
[[ $result -gt 0 ]] && compopt -o filenames 2> /dev/null;
fi;
return $result
}
_ufw ()
{
cur=${COMP_WORDS[COMP_CWORD]};
prev=${COMP_WORDS[COMP_CWORD-1]};
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=($( compgen -W "$(_ufw_commands)" $cur ));
else
if [ $COMP_CWORD -eq 2 ]; then
case "$prev" in
app)
COMPREPLY=($( compgen -W "$(_ufw_app_commands)" $cur ))
;;
status)
COMPREPLY=($( compgen -W "$(_ufw_status_commands)" $cur ))
;;
delete)
COMPREPLY=($( compgen -W "$(_ufw_rule_commands)" $cur ))
;;
logging)
COMPREPLY=($( compgen -W "$(_ufw_logging_commands)" $cur ))
;;
show)
COMPREPLY=($( compgen -W "$(_ufw_show_commands)" $cur ))
;;
default)
COMPREPLY=($( compgen -W "$(_ufw_default_commands)" $cur ))
;;
esac;
fi;
fi
}
_ufw_app_commands ()
{
ufw --help | sed -e '1,/^Application profile commands:/d' -e '/^ [^ ]/!d' -e 's/[ \t]\+app[ \t]\+\([a-z|]\+\)[ \t]\+.*/\1/g'
}
_ufw_commands ()
{
commands=$(ufw --help | sed -e '1,/^Commands:/d' -e '/^Application profile commands:/Q' -e 's/^[ \t]\+\([a-z|]\+\)[ \t]\+.*/\1/g' -e 's/|/ /g' | uniq);
echo "$commands app"
}
_ufw_default_commands ()
(未完)
你是用的Linux版本是CentOS7 吗? CentOS7 使用set命令后,显示就是这样的
shell编程之变量
51477 学习 · 76 问题
相似问题