diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2012-11-19 00:10:10 -0800 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2012-11-21 19:19:44 +0200 |
commit | db5c1817fabf7cbb9e4087b1576eb26f0747338e (patch) | |
tree | 43826772dc28adb382eeae0eeed79ffb831f2775 /src/xz/suffix.h | |
parent | xz: Fix the note about --rsyncable on the man page. (diff) | |
download | xz-db5c1817fabf7cbb9e4087b1576eb26f0747338e.tar.xz |
xzless: Make "less -V" parsing more robust
In v4.999.9beta~30 (xzless: Support compressed standard input,
2009-08-09), xzless learned to parse ‘less -V’ output to figure out
whether less is new enough to handle $LESSOPEN settings starting
with “|-”. That worked well for a while, but the version string from
‘less’ versions 448 (June, 2012) is misparsed, producing a warning:
$ xzless /tmp/test.xz; echo $?
/usr/bin/xzless: line 49: test: 456 (GNU regular expressions): \
integer expression expected
0
More precisely, modern ‘less’ lists the regexp implementation along
with its version number, and xzless passes the entire version number
with attached parenthetical phrase as a number to "test $a -gt $b",
producing the above confusing message.
$ less-444 -V | head -1
less 444
$ less -V | head -1
less 456 (no regular expressions)
So relax the pattern matched --- instead of expecting "less <number>",
look for a line of the form "less <number>[ (extra parenthetical)]".
While at it, improve the behavior when no matching line is found ---
instead of producing a cryptic message, we can fall back on a LESSPIPE
setting that is supported by all versions of ‘less’.
The implementation uses "awk" for simplicity. Hopefully that’s
portable enough.
Reported-by: Jörg-Volker Peetz <jvpeetz@web.de>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Diffstat (limited to 'src/xz/suffix.h')
0 files changed, 0 insertions, 0 deletions