Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 11 Jun 2012 08:45:30 +0200
From: Frank Dittrich <frank_dittrich@...mail.com>
To: john-dev@...ts.openwall.com
Subject: Re: GPU options

On 06/11/2012 07:53 AM, Frank Dittrich wrote:
> On 06/11/2012 01:44 AM, magnum wrote:
>> The bash completion just adopted, as-is. I really like that.
> 
> I guess I should remove LIST as a possible completion for --encoding= if
> --list=encodings is supported.
> 
> And if the john version knows --platform=, Ill use LIST as a possible
> completion.
> This needs to be fixed as well.

Done. See attached patch.
To be applied on top of 0001-Fix-bash-completion-for-unique.patch posted
in another reply, but there shouldn't be any conflicts.

Frank




>From beae71352fa9d6fa0a5095947030606edc60a77f Mon Sep 17 00:00:00 2001
From: Frank Dittrich <frank_dittrich@...mail.com>
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


Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ