>From beae71352fa9d6fa0a5095947030606edc60a77f Mon Sep 17 00:00:00 2001 From: Frank Dittrich Date: Mon, 11 Jun 2012 08:40:44 +0200 Subject: [PATCH 2/2] Adjust bash completion (--list=encodings and --list=opencl-devices) --- run/john.bash_completion | 26 ++++++++++++++++++++------ 1 files changed, 20 insertions(+), 6 deletions(-) diff --git a/run/john.bash_completion b/run/john.bash_completion index 028cf1a..5fc9431 100644 --- a/run/john.bash_completion +++ b/run/john.bash_completion @@ -417,12 +417,21 @@ _john() -?(-)en?(c|co|cod|codi|codin|coding)+(=|:)*) if [[ "${valopts}" == *--encoding=* ]] ; then # --encoding=LIST writes to stderr - encodings=`${first} --encoding=LIST 2>&1|grep -v 'Supported encodings'|sed 's#[,)]##g'|sed 's#(or ##g'` + list=`${first} --list=? 2>/dev/null|sed 's#\(,\)\?\( or\)\?[ ]*[<].*$##; s#,##g'` + if [[ "_${list}" == *encoding* ]] ; then + cmd="${first} --list=encodings" + else + cmd="${first} --encoding=LIST" + fi + encodings=`${cmd} 2>&1|grep -v 'Supported encodings'|sed 's#[,)]##g'|sed 's#(or ##g'` cur=${cur#*[=:]} if [[ ${COMP_CWORD} -eq 2 || ${COMP_CWORD} -eq 3 && "_${cur}" != "_" ]] ; then - encodings="${encodings} LIST" - # make sure LIST will be the first option: - LC_ALL=C + # Don't add LIST if --list=encodings is supported + if [[ "_${list}" != *encoding* ]] ; then + encodings="${encodings} LIST" + # make sure LIST will be the first option: + LC_ALL=C + fi fi COMPREPLY=( $(compgen -W "${encodings}" -- ${cur}) ) fi @@ -486,18 +495,23 @@ _john() return 0 ;; -?(-)+(pla?(t|tf|tfo|tfor|tform)|d?(e|ev|evi|evic|evice))+(=|:)[Ll]?([Ii]|[Ii][Ss]|[Ii][Ss][Tt])) + list=`${first} --list=? 2>/dev/null|sed 's#\(,\)\?\( or\)\?[ ]*[<].*$##; s#,##g'` + # Only complete to lIST if --list=cuda-devices and --list=opencl-devices don't exist # CUDA doesn't allow --device=LIST # workaround: check if --platform= is allowed - if [[ "${valopts}" == *--platform=* ]] ; then + if [[ "${valopts}" == *--platform=* && "_${list}" != *-devices* ]] ; then cur=`echo ${cur#*[=:]}|LC_ALL=C tr a-z A-Z` COMPREPLY=( $(compgen -W "LIST" -- ${cur}) ) fi return 0 ;; -?(-)+(pla?(t|tf|tfo|tfor|tform)|d?(e|ev|evi|evic|evice))+(=|:)) + list=`${first} --list=? 2>/dev/null|sed 's#\(,\)\?\( or\)\?[ ]*[<].*$##; s#,##g'` + # Only list possible completions if --list=cuda-devices + # and --list=opencl-devices don't exist. # --device=LIST isn't supported for CUDA, but for CUDA # --platform= is not a valid option - if [[ "${valopts}" == *--platform=* ]] ; then + if [[ "${valopts}" == *--platform=* && "_${list}" != *-devices* ]] ; then # Calling john --platform=LIST just to find possible completions # will take too long cur=${cur#*[=:]} -- 1.7.7.6