From 6586b61384cff33d2c3ce6512c714e20ea59bfed Mon Sep 17 00:00:00 2001 From: silenc3r Date: Fri, 6 Mar 2020 07:04:58 +0100 Subject: [PATCH] Avoid race condition when listing matches (#238) --- z.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/z.sh b/z.sh index e7120eb..f9ec16a 100644 --- a/z.sh +++ b/z.sh @@ -147,15 +147,15 @@ _z() { function output(matches, best_match, common) { # list or return the desired directory if( list ) { + if( common ) { + printf "%-10s %s\n", "common:", common > "/dev/stderr" + } cmd = "sort -n >&2" for( x in matches ) { if( matches[x] ) { printf "%-10s %s\n", matches[x], x | cmd } } - if( common ) { - printf "%-10s %s\n", "common:", common > "/dev/stderr" - } } else { if( common ) best_match = common print best_match