Ouch, it seems like my editor ate a newline in the diff; sorry. Hopefully this works better...

diff --git a/src/password-store.sh b/src/password-store.sh
index 77f3eda..ce3f7fb 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -99,7 +99,7 @@ set_gpg_recipients() {
   verify_file "$current"
 
   local gpg_id
-	while read -r gpg_id; do
+  grep -Eo '^[^#]+' | grep -Ev '^\s*$' | while read -r gpg_id; do
     GPG_RECIPIENT_ARGS+=( "-r" "$gpg_id" )
     GPG_RECIPIENTS+=( "$gpg_id" )
   done < "$current"

/Rune

"Rune Juhl Jacobsen" <[email protected]> writes:

I would probably reach for grep and do something like this instead: diff --git a/src/password-store.sh b/src/password-store.sh index 77f3eda..ce3f7fb 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -99,7 +99,7 @@ set_gpg_recipients() { verify_file "$current" local gpg_id - while read -r gpg_id; do + grep -Eo '^[^#]+' | grep -Ev '^\s*$' | while read -r gpg_id; do GPG_RECIPIENT_ARGS+=( "-r" "$gpg_id" ) GPG_RECIPIENTS+=( "$gpg_id" ) done < "$current" This will remove comments no matter if they're full lines or not, and will remove any lines containing only whitespace as well. I'm not sure about using `grep -E` though. It's more portable than `grep -e` or `egrep`, but I'm not sure if it'd be better to use `grep -P`, or if it's better to simply loop over all lines and use Bash regexes and BASH_REMATCH to remove comments and empty lines. /Rune "Amir Yalon" <[email protected]> writes:
On Tue, Dec 17, 2019, at 18:55, Kjetil Torgrim Homme wrote:
- while read -r gpg_id; do + while read -r gpg_id additional_columns; do + case $additional_columns in + ""|"# "*) : ;; # only keep first column, strip comment + *) gpg_id="${gpg_id} ${additional_columns}" ;; + esac
It may be simpler to do gpg_id="${gpg_id%%#*}" instead. _______________________________________________ Password-Store mailing list [email protected] https://lists.zx2c4.com/mailman/listinfo/password-store

-- Rune Juhl Jacobsen [email protected] +45 6016 8337

--
Rune Juhl Jacobsen
[email protected]
+45 6016 8337
_______________________________________________
Password-Store mailing list
[email protected]
https://lists.zx2c4.com/mailman/listinfo/password-store

Reply via email to