[pass] [PATCH 1/1] sed(1) compatibility

Kjetil Torgrim Homme kjetil.homme at redpill-linpro.com
Tue Feb 9 17:05:43 CET 2016

On 02/09/2016 03:05 PM, Lucas Hoffmann wrote:
> You could also try to split the job into two regexes if there are too
> many differences between the sed versions we want to support.
> `man tree` says that it will use $LS_COLORS. But as far as I understand
> it after some tests, this arbitrary escape sequence will only be used at
> the start of the file name.  After the file name it will always be
> "\e[00m".

no, this is dependent on your $TERM and your terminfo.  on my system, it
is "\e[0m", but it could be "\e[27m" as well (output from tput rmso).
of course, if $TERM is not a VT102 dialect, there is no telling what it
will look like, but it's probably not worthwhile to support such edge
cases :-)

> So my idea is to remove the check for arbitrary escape
> sequences after the gpg extension.  The file name on the other hand
> could contain the string ".gpg\e[00m -> " but I think we should not
> support that.
> So we could simplify the regex and use two sed commands (but not two
> invocations of sed) like this:
> tree ... | sed \
>   -e 's/\.gpg\(\x1b\[00m\)\{0,1\} -> /\1 -> /'  \
>   -e 's/\.gpg\(\x1b\[00m\)\{0,1\}$/\1/'

I support splitting up the expression, it is much easier to read.  but
do use "[0-9]+" instead of "00"

> Explanation: First we find a .gpg extension, possibly followed by a
> terminal attribute reset sequence, followed by an ascii arrow.  We
> remove the .gpg extension and leave the rest of the match intact.  This
> is *not* done globally.  So if this is found in any filename the output
> will be faulty.
> Next we find a .gpg and possibly the reset sequence at the end of a line
> and again only remove the .gpg extension.
> Now we have a regex without branches and can hopefully get it to work on
> all sed implementations.
> Obviously: Comments, bug reports, criticts ... welcome.

Kjetil T. Homme
Redpill Linpro - Changing the game

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20160209/88a3e5b6/attachment.asc>

More information about the Password-Store mailing list