From e3fc254fc620b3533dd58a06ceaaf45ca372aed6 Mon Sep 17 00:00:00 2001 From: Einhard Leichtfuß Date: Sat, 29 Dec 2018 19:15:25 +0100 Subject: Fix return value in display_exact Also, - declare constant variables actually as constant. - use `-mindepth 1' in addition to `-maxdepth 1' for find. --- ctct.in | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'ctct.in') diff --git a/ctct.in b/ctct.in index 89d9fc4..d03112f 100644 --- a/ctct.in +++ b/ctct.in @@ -40,11 +40,11 @@ test -f "$user_config_file" \ && source "$user_config_file" ## CONSTANTS: -exec_name="${0##*/}" -RET_SUCCESS=@ret_success@ -RET_FAILURE=@ret_failure@ -RET_BADSYNTAX=@ret_badsyntax@ -RET_ERROR=@ret_error@ +typeset -r exec_name="${0##*/}" +typeset -r RET_SUCCESS=@ret_success@ +typeset -r RET_FAILURE=@ret_failure@ +typeset -r RET_BADSYNTAX=@ret_badsyntax@ +typeset -r RET_ERROR=@ret_error@ # Expand non matching globs to the empty string instead of themselves. @@ -180,8 +180,8 @@ function display_exact() "${visual_program[@]}" < "$file" || return $RET_ERROR else "${output_program[@]}" < "$file" | "${visual_program[@]}" - [[ ${PIPESTATUS[0]} -eq 0 || ${PIPESTATUS[1]} -eq 0 ]] \ - || return $RET_ERROR + [[ ${PIPESTATUS[0]} -ne 0 || ${PIPESTATUS[1]} -ne 0 ]] \ + && return $RET_ERROR fi return $RET_SUCCESS @@ -284,7 +284,8 @@ function list_all() [[ "$1" == 'full_path' ]] && fmt='%p\n' || fmt='%f\n' # Only list regular files with valid names. - find "$datadir" -maxdepth 1 -type f -regextype posix-extended -regex \ + find "$datadir" -mindepth 1 -maxdepth 1 -type f \ + -regextype posix-extended -regex \ '.*/[[:alpha:]]+([-_][[:alpha:]]+)*(\.[[:alpha:]]+([-_][[:alpha:]]+)*)?' \ -printf "$fmt" -- cgit v1.2.3