diff --git a/find-first-fail/find-first-fail b/find-first-fail/find-first-fail index fcd8019..6c1d21c 100755 --- a/find-first-fail/find-first-fail +++ b/find-first-fail/find-first-fail @@ -10,7 +10,7 @@ find-first-fail - find the lowest argument that makes a command fail =head1 SYNOPSIS -B [-2] [-q] I +B [-2] [-q] [-s I] I =head1 DESCRIPTION @@ -39,6 +39,10 @@ arguments: I I. Quiet. Ignore output from I. +=item B<-s I> + +Start searching from the value I. Normally searching will start from the value 1. + =back @@ -164,20 +168,22 @@ find-first-fail() { quiet="" opt2=false verbose=false - + start=1 + # Parse and remove options - while getopts "2vq" options; do + while getopts "2vqs:" options; do case "${options}" in (2) opt2=true;; (q) quiet=">/dev/null 2>/dev/null";; (v) verbose=true;; + (s) start="$2";; (-) break;; esac done shift $(( OPTIND - 1)) - + # If function(1) = false: run 'not function()' instead - if _run 1 1 "$@" ; then + if _run "$start" "$start" "$@" ; then not='' else not='!' @@ -186,8 +192,8 @@ find-first-fail() { # exponential search for the first value that is false # low = previous value (function($low) == true) # high = low * 2 (function($high) == false) - high=1 - while _run 1 $high "$@" ; do + high=$start + while _run $start $high "$@" ; do low=$high high=$(( $high*2 )) if [ $high -gt 4611686018427387900 ] ; then