> -             grepresults="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | grep 
> --color=always "$@")"
> -             [[ $? -ne 0 ]] && continue
> -             passfile="${passfile%.gpg}"
> -             passfile="${passfile#$PREFIX/}"
> -             local passfile_dir="${passfile%/*}/"
> -             [[ $passfile_dir == "${passfile}/" ]] && passfile_dir=""
> -             passfile="${passfile##*/}"
> -             printf "\e[94m%s\e[1m%s\e[0m:\n" "$passfile_dir" "$passfile"
> -             echo "$grepresults"
> +             if grepresults="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | grep 
> --color=always "$@")";
> +             then
> +                     passfile="${passfile%.gpg}"
> +                     passfile="${passfile#$PREFIX/}"
> +                     local passfile_dir="${passfile%/*}/"
> +                     [[ $passfile_dir == "${passfile}/" ]] && passfile_dir=""
> +                     passfile="${passfile##*/}"
> +                     printf "\\e[94m%s\\e[1m%s\\e[0m:\\n" "$passfile_dir" 
> "$passfile"
> +                     echo "$grepresults"
> +             fi

How about this?

grepresults="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | grep --color=always 
"$@")" || continue

This way, we don't need an indented if block.

This patch looks good to me, and I'm glad that people are using shellcheck.
By the way, it might be helpful to include the path to source files in a
comment line above the source commands, that way shellcheck can do more
thorough checking. I haven't used that a lot, but if it takes a relative
path, it should work.


--

Oliver
_______________________________________________
Password-Store mailing list
[email protected]
https://lists.zx2c4.com/mailman/listinfo/password-store

Reply via email to