aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinhard Leichtfuß <alguien@respiranto.de>2018-12-29 19:15:25 +0100
committerEinhard Leichtfuß <alguien@respiranto.de>2018-12-29 19:18:33 +0100
commite3fc254fc620b3533dd58a06ceaaf45ca372aed6 (patch)
tree30e71ee120f66ae1b13ed694859128b720c23328
parent71e8231e4937d8763cf9b005560faa599bc71bec (diff)
downloadctct-e3fc254fc620b3533dd58a06ceaaf45ca372aed6.tar.gz
ctct-e3fc254fc620b3533dd58a06ceaaf45ca372aed6.tar.xz
Fix return value in display_exact
Also, - declare constant variables actually as constant. - use `-mindepth 1' in addition to `-maxdepth 1' for find.
-rw-r--r--TODO1
-rw-r--r--ctct.in17
2 files changed, 10 insertions, 8 deletions
diff --git a/TODO b/TODO
index a23117d..c533ed0 100644
--- a/TODO
+++ b/TODO
@@ -25,6 +25,7 @@ TODO file for ctct
* [consider] Use regexes for --search-by-name.
* [consider] For --search-by_data, use the '.' als alternative conjugation
separator.
+* Allow combination of --search-by-data and --search-by-name.
[INTERNAL]
* Be consistent in usage of [, test, [[.
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"