당신은 setfacl --help
을 실행하여 사용 정보를 구문 분석하고 modificator이 포함 된 경우 확인할 수 있습니다. 예를 들면 : 당신이 --help
옵션이있는 명령을 수행 할 경우
if setfacl --help | grep -q -- -m,
then
echo "setfacl -m supported"
else
echo "setfacl -m not supported"
fi
, 당신의 bash는 완성 파일에서 사용할 수있는 _parse_help
기능을 살펴.
# Parse GNU style help output of the given command.
# @param $1 command; if "-", read from stdin and ignore rest of args
# @param $2 command options (default: --help)
#
_parse_help()
{
eval local cmd=$(quote "$1")
local line
{ case $cmd in
-) cat ;;
*) LC_ALL=C "$(dequote "$cmd")" ${2:---help} 2>&1 ;;
esac } \
| while read -r line; do
[[ $line == *([ $'\t'])-* ]] || continue
# transform "-f FOO, --foo=FOO" to "-f , --foo=FOO" etc
while [[ $line =~ \
((^|[^-])-[A-Za-z0-9?][[:space:]]+)\[?[A-Z0-9]+\]? ]]; do
line=${line/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"}
done
__parse_options "${line// or /, }"
done
}
http://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git;a=blob;f=bash_completion
그냥 생각?은'$를 확인하는'정의되지 않은 modificator으로 실행될 때 대부분의 명령은'1'을 반환하기 때문에 '0'상태. 다른 사람들은 단지 그들을 무시하지만 ... – tamasgalmodifator를 가진 정규 호출 명령은 파일 시스템에 영향을 줄 수 있습니다. 일부 샌드 박스 호출을 찾고 있습니다. – hsz
명령에'--help' 출력이 있습니까? 아마 수정자를 "grepping";) – tamasgal