>From b4675a2f4f1e91e50d657648fd0e444e9c85378a Mon Sep 17 00:00:00 2001 From: Frank Dittrich Date: Fri, 8 Jun 2012 20:57:01 +0200 Subject: [PATCH] bash completion: a few more improvements Format names are always converted to lower case, even if the usage output uses upper / mixed case. A few other options in addition to --format= now work with a more relaxed upper/lower case handling. Since --device is the only option name starting with --d, completion for -d= and --de: is now similar to the one for --dev= or --device=. --- run/john.bash_completion | 27 ++++++++++----------------- 1 files changed, 10 insertions(+), 17 deletions(-) diff --git a/run/john.bash_completion b/run/john.bash_completion index 31e008c..363a5e3 100644 --- a/run/john.bash_completion +++ b/run/john.bash_completion @@ -164,8 +164,8 @@ _john() return 0 fi fi - cur=${cur#*[=:]} - formats=`${first} |sed -n '/^--format/,$ { s#^--format=[ A-Za-z]*:##; /^--/ b; s#^ *##; s#\#dynamic#; s#[/ ]#\n#g; p }'` + cur=`echo ${cur#*[=:]}|LC_ALL=C tr A-Z a-z` + formats=`${first} |sed -n '/^--format/,$ { s#^--format=[ A-Za-z]*:##; /^--/ b; s#^ *##; s#\#dynamic#; s#^\(.*\)$#\L\1#; s#[/ ]#\n#g; p }'` COMPREPLY=( $(compgen -W "${formats}" -- ${cur}) ) if [[ "${COMPREPLY[0]}_" == dynamic_ ]] ; then compopt -o nospace @@ -384,16 +384,9 @@ _john() fi return 0 ;; - -?(-)sho?(w)+(=|:)l*) - if [[ "${valopts}" == *--show* ]] ; then - cur=${cur#*[=:]} - COMPREPLY=( $(compgen -W "left" -- ${cur}) ) - fi - return 0 - ;; - -?(-)sho?(w)+(=|:)*) + -?(-)sho?(w)+(=|:)?([Ll]|[Ll][Ee]|[Ll][Ee][Ff]|[Ll][Ee][Ff][Tt])) if [[ "${valopts}" == *--show* ]] ; then - cur=${cur#*[=:]} + cur=`echo ${cur#*[=:]}|LC_ALL=C tr a-z A-Z` COMPREPLY=( $(compgen -W "LEFT" -- ${cur}) ) fi return 0 @@ -473,11 +466,11 @@ _john() ;; -?(-)su?(b|bf|bfo|bfor|bform|bforma|bformat)+(=|:)*) if [[ "${options}" == *--subformat=LIST* ]] ; then - cur=${cur#*[=:]} + cur=`echo ${cur#*[=:]}|LC_ALL=C tr a-z A-Z` COMPREPLY=( $(compgen -W "LIST" -- ${cur}) ) else if [[ "${hidden}" == *--subformat=* ]] ; then - cur=${cur#*[=:]} + cur=`echo ${cur#*[=:]}|LC_ALL=C tr A-Z a-z` # Should I test if --format=crypt (or -fo:crypt ...) is specified? # Should I really parse the output of # $[first} --test --format=crypt --subformat=? @@ -492,16 +485,16 @@ _john() fi return 0 ;; - -?(-)pla?(t|tf|tfo|tfor|tform)+(=|:)+(L|l)*|-?(-)dev?(i|ic|ice)+(=|:)+(L|l)*) + -?(-)+(pla?(t|tf|tfo|tfor|tform)|d?(e|ev|evi|evic|evice))+(=|:)[Ll]?([Ii]|[Ii][Ss]|[Ii][Ss][Tt])) # CUDA doesn't allow --device=LIST # workaround: check if --platform= is allowed if [[ "${valopts}" == *--platform=* ]] ; then - cur=${cur#*[=:]} - COMPREPLY=( $(compgen -W "LIST list" -- ${cur}) ) + cur=`echo ${cur#*[=:]}|LC_ALL=C tr a-z A-Z` + COMPREPLY=( $(compgen -W "LIST" -- ${cur}) ) fi return 0 ;; - -?(-)platform+(=|:)|-?(-)device+(=|:)) + -?(-)+(pla?(t|tf|tfo|tfor|tform)|d?(e|ev|evi|evic|evice))+(=|:)) # --device=LIST isn't supported for CUDA, but for CUDA # --platform= is not a valid option if [[ "${valopts}" == *--platform=* ]] ; then -- 1.7.7.6