From a14aa4c86d8fdafefd85d24dce02aff45f6d6fab Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Fri, 2 Nov 2018 03:11:38 -0400 Subject: [PATCH] minimal/do whichdo: should print ../default.do if ../$1.do exists. It would be incorrect to print ../$1.do (we only use $1.do in the *current* directly, not prefix dirs; we only use default*.do in those). However, when we found ../default.do, we forgot to print it, because of a silly logic error. --- minimal/do | 3 ++- t/260-whichdo/all.do | 2 +- t/260-whichdo/defaults.do | 16 ++++++++++++++++ t/260-whichdo/fakesub2/default.do | 1 + t/260-whichdo/fakesub2/snork.do | 1 + 5 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 t/260-whichdo/defaults.do create mode 100644 t/260-whichdo/fakesub2/default.do create mode 100644 t/260-whichdo/fakesub2/snork.do diff --git a/minimal/do b/minimal/do index 61889d9..3091fae 100755 --- a/minimal/do +++ b/minimal/do @@ -208,10 +208,11 @@ _find_dofiles() _dirsplit "$dofile" dodir=$_dirsplit_dir dofile=$_dirsplit_base + [ -n "$dodir" ] && dodir=${dodir%/}/ + [ -e "$dodir$dofile" ] && return 0 for i in $(seq 100); do [ -n "$dodir" ] && dodir=${dodir%/}/ #echo "_find_dofiles: '$dodir' '$dofile'" >&2 - [ -e "$dodir$dofile" ] && return 0 _find_dofiles_pwd "$dodir" "$dofile" && return 0 newdir=$(_normpath "${dodir}..") [ "$newdir" = "$dodir" ] && break diff --git a/t/260-whichdo/all.do b/t/260-whichdo/all.do index 1beaa06..d4d93b6 100644 --- a/t/260-whichdo/all.do +++ b/t/260-whichdo/all.do @@ -1 +1 @@ -redo exists nonexists +redo exists nonexists defaults diff --git a/t/260-whichdo/defaults.do b/t/260-whichdo/defaults.do new file mode 100644 index 0000000..0fe3214 --- /dev/null +++ b/t/260-whichdo/defaults.do @@ -0,0 +1,16 @@ +exec >&2 + +a=$(cd fakesub2 && redo-whichdo d/snork) +# if sh doesn't abort after the above, then it found a .do file as expected + +b=$(cat <