commit 7a322a38e5daed5ac6154e9d5cbfaab5387b2117
parent 98c8a6b7e0385e49c706bcdb9c24f15789576968
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Tue, 11 Nov 2025 18:37:02 +0000
Environment of `do_list` is set on all calls
Diffstat:
3 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/spec/action_spec.sh b/spec/action_spec.sh
@@ -1805,6 +1805,9 @@ Describe 'Action Functions'
#|subdir/subsub/old
#|subdir.gpg
}
+ BEGIN_GPG_NAME=''
+ END_GPG_NAME=''
+ LIST_EMPTY='no'
When call do_list ''
The status should be success
The output should equal "$(result)"
@@ -1820,6 +1823,8 @@ Describe 'Action Functions'
#|subdir/subsub/old
#|subdir.gpg
}
+ BEGIN_GPG_NAME=''
+ END_GPG_NAME=''
LIST_EMPTY=yes
When call do_list ''
The status should be success
@@ -1833,18 +1838,27 @@ Describe 'Action Functions'
#|other/lower.gpg
#|subdir/subsub/old
}
+ BEGIN_GPG_NAME=''
+ END_GPG_NAME=''
+ LIST_EMPTY='no'
When call do_list '' -i L
The status should be success
The output should equal "$(result)"
End
It 'does not display matching directories'
+ BEGIN_GPG_NAME=''
+ END_GPG_NAME=''
+ LIST_EMPTY='no'
When call do_list '' t
The status should be success
The output should equal 'root'
End
It 'might not display anything'
+ BEGIN_GPG_NAME=''
+ END_GPG_NAME=''
+ LIST_EMPTY='no'
When call do_list '' z
The status should be success
The output should equal ''
@@ -1861,6 +1875,7 @@ Describe 'Action Functions'
}
BEGIN_GPG_NAME='['
END_GPG_NAME=']'
+ LIST_EMPTY='no'
When call do_list ''
The status should be success
The output should equal "$(result)"
diff --git a/spec/pashage_extra_spec.sh b/spec/pashage_extra_spec.sh
@@ -1291,26 +1291,6 @@ Describe 'Integrated Command Functions'
The output should equal "$(expected_out)"
End
- It 'displays the whole store and empty directories as a raw list'
- LIST_EMPTY=yes
- When call cmd_list_or_show --raw
- The status should be success
- The error should be blank
- expected_out() { %text
- #|extra/subdir/file
- #|extra/subdir.gpg
- #|fluff/one
- #|fluff/three
- #|fluff/two
- #|old
- #|shared/
- #|stale
- #|stale.gpg
- #|subdir/file
- }
- The output should equal "$(expected_out)"
- End
-
It 'displays a subdirectory as a raw list'
When call cmd_list_or_show -r fluff
The status should be success
diff --git a/src/pashage.sh b/src/pashage.sh
@@ -850,8 +850,8 @@ do_insert() {
# Display the entry list rooted at the given relative directory
# $1: path relative to prefix
# ...: (optional) grep arguments to filter
-# BEGIN_GPG_NAME: (optional) marker before gpg secret name
-# END_GPG_NAME: (optional) marker after gpg secret name
+# BEGIN_GPG_NAME: marker before gpg secret name
+# END_GPG_NAME: marker after gpg secret name
# HAS_ITEMS: (output) set to `yes` when something has been printed
# LIST_EMPTY: include empty directories in output when set to `yes`
# Note that this function is recrusive and cannot use variables to hold state
@@ -865,7 +865,7 @@ do_list() {
set -- "${ENTRY}" "$@"
HAS_ITEMS=no
do_list "$@"
- if [ "${LIST_EMPTY-}${HAS_ITEMS}" = 'yesno' ]; then
+ if [ "${LIST_EMPTY}${HAS_ITEMS}" = 'yesno' ]; then
printf '%s/\n' "$1"
fi
HAS_ITEMS=yes
@@ -893,9 +893,9 @@ do_list() {
ITEM_NAME="${ITEM_NAME%.gpg}"
fi
printf '%s%s%s\n' \
- "${BEGIN_GPG_NAME-}" \
+ "${BEGIN_GPG_NAME}" \
"${ITEM_NAME}" \
- "${END_GPG_NAME-}"
+ "${END_GPG_NAME}"
HAS_ITEMS=yes
fi
fi
@@ -911,7 +911,13 @@ do_list() {
do_list_or_show() {
if [ -z "$1" ]; then
if [ "${LIST_VIEW-no}" = "yes" ]; then
+ BEGIN_GPG_NAME=''
+ END_GPG_NAME=''
+ LIST_EMPTY='no'
do_list ''
+ unset BEGIN_GPG_NAME
+ unset END_GPG_NAME
+ unset LIST_EMPTY
else
printf 'Password Store\n'
do_tree ''
@@ -924,7 +930,13 @@ do_list_or_show() {
unset SECRET
elif [ -d "${PREFIX}/$1" ]; then
if [ "${LIST_VIEW-no}" = "yes" ]; then
+ BEGIN_GPG_NAME=''
+ END_GPG_NAME=''
+ LIST_EMPTY='no'
do_list "${1%/}"
+ unset BEGIN_GPG_NAME
+ unset END_GPG_NAME
+ unset LIST_EMPTY
else
printf '%s\n' "${1%/}"
do_tree "${1%/}"
@@ -1305,7 +1317,13 @@ cmd_find() {
fi
if [ "${LIST_VIEW}" = yes ]; then
+ BEGIN_GPG_NAME=''
+ END_GPG_NAME=''
+ LIST_EMPTY='no'
do_list '' "$@"
+ unset BEGIN_GPG_NAME
+ unset END_GPG_NAME
+ unset LIST_EMPTY
else
printf 'Search pattern: %s\n' "$*"
do_tree '' "$@"