[PATCH] Allow comments in .gpg-id

Rune Juhl Jacobsen rune at juhljacobsen.dk
Wed Dec 18 11:39:45 CET 2019


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-diff
Size: 424 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20191218/ab3fa47a/attachment.diff>
-------------- next part --------------

/Rune

"Rune Juhl Jacobsen" <rune at juhljacobsen.dk> 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" <quoiceehoh-20180826 at yxejamir.net> 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 Password-Store at lists.zx2c4.com 
>> https://lists.zx2c4.com/mailman/listinfo/password-store  
> 
> --  Rune Juhl Jacobsen rune at juhljacobsen.dk +45 6016 8337 

-- 
Rune Juhl Jacobsen
rune at juhljacobsen.dk
+45 6016 8337


More information about the Password-Store mailing list