commit 40b877bcd5785b43a6fc0b298a91eb895a583262
parent 0bb8d7eb7f32e7286ff1c3c6f1c0c855b27159e4
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Sun, 15 Sep 2024 12:42:12 +0000
Find command outputs the search pattern even without match
Diffstat:
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/spec/action_spec.sh b/spec/action_spec.sh
@@ -1618,5 +1618,10 @@ Describe 'Action Functions'
When call do_tree "${PREFIX}" 'Title' z
The output should equal ''
End
+
+ It 'does not display an empty title'
+ When call do_tree "${PREFIX}" '' t
+ The output should equal 'L_root'
+ End
End
End
diff --git a/spec/usage_spec.sh b/spec/usage_spec.sh
@@ -356,9 +356,8 @@ Describe 'Command-Line Parsing'
It 'uses the argument list directly'
When call cmd_find -i pattern
- The output should be blank
- The error should equal \
- '$ do_tree /prefix Search pattern: -i pattern -i pattern'
+ The output should equal 'Search pattern: -i pattern'
+ The error should equal '$ do_tree /prefix -i pattern'
End
It 'reports a lack of argument'
diff --git a/src/pashage.sh b/src/pashage.sh
@@ -927,9 +927,11 @@ do_tree_cwd() {
fi
if [ $# -eq 0 ] || [ -n "${ACC}" ]; then
- printf '%s\n' "${TITLE}" "${ACC}"
+ [ -n "${TITLE}" ] && printf '%s\n' "${TITLE}"
fi
+ [ -n "${ACC}" ] && printf '%s\n' "${ACC}"
+
unset ACC
unset PREV
unset TITLE
@@ -1088,7 +1090,8 @@ cmd_find() {
exit 1
fi
- do_tree "${PREFIX}" "Search pattern: $*" "$@"
+ printf 'Search pattern: %s\n' "$*"
+ do_tree "${PREFIX}" '' "$@"
}
cmd_generate() {