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
signature.asc
Description: signature
_______________________________________________ Password-Store mailing list [email protected] http://lists.zx2c4.com/mailman/listinfo/password-store
