From c8a6cba61697c02ecc2e3c5db27629630d9fade2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 22:15:59 +1300 Subject: Move error increment to outside of if block --- bash/bashrc.d/keep.bash | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'bash/bashrc.d/keep.bash') diff --git a/bash/bashrc.d/keep.bash b/bash/bashrc.d/keep.bash index a39d2fa7..2eebdae3 100644 --- a/bash/bashrc.d/keep.bash +++ b/bash/bashrc.d/keep.bash @@ -101,19 +101,17 @@ EOF # If -d was given, delete the keep files for the NAME if ((delete)) ; then - rm -- "$bashkeep"/"$name".bash || - ((errors++)) + rm -- "$bashkeep"/"$name".bash # Save a function elif [[ $(type -t "$name") = 'function' ]] ; then - declare -f -- "$name" >"$bashkeep"/"$name".bash || - ((errors++)) + declare -f -- "$name" >"$bashkeep"/"$name".bash # Save a variable elif declare -p -- "$name" >/dev/null ; then - declare -p -- "$name" >"$bashkeep"/"$name".bash || - ((errors++)) - fi + declare -p -- "$name" >"$bashkeep"/"$name".bash + + fi || ((errors++)) ;; esac done -- cgit v1.2.3 From 8d2670642c6de689948257bcdd7097e53ced83cb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 2 Dec 2018 22:16:25 +1300 Subject: Use simple loop rather than glob tricks in keep --- bash/bashrc.d/keep.bash | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'bash/bashrc.d/keep.bash') diff --git a/bash/bashrc.d/keep.bash b/bash/bashrc.d/keep.bash index 2eebdae3..48196aeb 100644 --- a/bash/bashrc.d/keep.bash +++ b/bash/bashrc.d/keep.bash @@ -130,12 +130,12 @@ EOF # Otherwise the user must want us to print all the NAMEs kept ( shopt -s nullglob - declare -a keeps - keeps=("$bashkeep"/*.bash) - keeps=("${keeps[@]##*/}") - keeps=("${keeps[@]%.bash}") - ((${#keeps[@]})) || exit 0 - printf '%s\n' "${keeps[@]}" + for keep in "$bashkeep"/*.bash ; do + ! [[ -d $keep ]] || continue + keep=${keep##*/} + keep=${keep%.bash} + printf '%s\n' "$keep" + done ) } -- cgit v1.2.3