]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
Fix version.sh compatiblity with Solaris
authorLasse Collin <lasse.collin@tukaani.org>
Mon, 3 Jun 2024 13:55:03 +0000 (16:55 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Fri, 6 Sep 2024 15:51:58 +0000 (18:51 +0300)
The ancient /bin/tr on Solaris doesn't support '\n'.
With /usr/xpg4/bin/tr it works but it might not be in PATH.

Another problem was that sed was given input that didn't have a newline
at the end. Text files must end with a newline to be portable.

Fix both problems:

  - Handle multiline input within sed itself to avoid one tr invocation.
    The default sed even on Solaris does understand \n.

  - Use octals in tr -d. \012 works for ASCII "line feed", it's even
    used as an example in the Solaris man page. But we must strip
    also ASCII "carriage return" \015 and EBCDIC "next line" \025.
    The EBCDIC case got handled with \n previously. Stripping \012
    and \015 on EBCDIC system won't matter as those control chars
    won't be present in the string in the first place.

An awk-based solution could be an alternative but it might need
special casing on Solaris to used nawk instead of awk. The changes
in this commit are smaller and should have a smaller risk for
regressions. It's also possible that version.sh will be dropped
entirely at some point.

(cherry picked from commit e7a42cda7c827e016619e8cab15e2faf5d4181ae)

build-aux/version.sh

index bef1b33d9f408589959dc472d399d90e65684e27..d1a12a941d2a6f271febfbe99574806940c1f00c 100644 (file)
@@ -17,6 +17,5 @@ sed -n 's/LZMA_VERSION_STABILITY_ALPHA/alpha/
        s/LZMA_VERSION_STABILITY_STABLE//
        s/^#define LZMA_VERSION_[MPS][AIT][AJNT][A-Z]* //p' \
        src/liblzma/api/lzma/version.h \
-       | tr '\n' '|' \
-       | sed 's/|/./; s/|/./; s/|//g' \
-       | tr -d '\r\n'
+       | sed 'N; N; N; s/\n/./g; s/\.$//' \
+       | tr -d '\012\015\025'