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

Lucas Hoffmann l-m-h at web.de
Tue Feb 9 15:05:56 CET 2016


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".  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/'

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.

Lucas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: signature
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20160209/31467a40/attachment.asc>


More information about the Password-Store mailing list