[Forgot attachments]

On 2024-06-14 23:22, Brian Inglis via Cygwin-apps wrote:
I would like to provide a Cygwin package for lesspipe, to automatically
show archive contents or information about many file types, with
enhanced or coloured output, without having to remember which filter
commands are required to do so, as I have been using it for many years.

Description:
Converts many file formats to text with coloured or enhanced display,
so their contents or useful information about their contents can be shown.
See the less(1) man page section INPUT PREPROCESSOR.
The input filter is a bash script, which also works under zsh, and is
easily extensible for new formats.
Tab completion mechanisms for archive contents are provided for bash and zsh.
Also works with git version control, mutt mail client, vim text editor.
Can handle a wide variety of file formats, even files compressed and
contained in a hierarchy of archives, enabling users to deeply inspect
archives, and display the contents of files in archives without having
to unpack them.
Converters are checked for and used if available, including Cygwin packages:
        antiword                MS Word files
        binutils                text strings in binary files or archives
        brotli                  compressed files or archives
        bsdtar                  archive files
        bzip2                   compressed files or archives
        cabextract              MS Cabinet files
        catdoc                  MS Word files
        cpio                    archive files
        djvulibre               DjVu files
        genisoimage             ISO files or images
        ghostscript             PS files
        groff                   man pages or Unix source documents
        gzip                    compressed files or archives
        hdf5                    HDF v5 files
        id3v2                   media files
        ImageMagick             image files
        jq                      JSON data files
        libiconv                character set code page conversion
        lynx                    HTML files
        lz4                     compressed files or archives
        lzip                    compressed files or archives
        mediainfo               media files
        netcdf                  nc4 NetCDF files
        odt2txt                 OpenDocument files
        openssl                 Digital Security Certificates
        p7zip                   archive files
        perl-Image-ExifTool     media files
        poppler                 PDF files
        python39-pygments       program source code files
        rpm                     RPM files
        source-highlight        program source code files
        texlive                 TeX files
        unrtf                   RTF files
        unzip                   zip files
        util-linux              tabular data files
        w3m                     HTML files
        wordview                MS Office files
        writerperfect           MS Office files
        wv                      MS Word files
        xlsx2csv                MS Excel files
        xz                      compressed files or archives
        zstd                    compressed files or archives.
To use these, select them for install in the Cygwin Setup program.

License:        GPL-2.0-or-later

It may be enabled by running interactively:

        $ eval `/usr/bin/lesspipe.sh`

or adding to a login profile the command:

        eval $(/usr/bin/lesspipe.sh)

For more information see the project home pages:

        https://www-zeuthen.desy.de/~friebel/unix/lesspipe.html

        https://github.com/wofr06/lesspipe

It is packaged by Arch, FreeBSD, Gentoo, MacPorts, and some minor distros:

        https://repology.org/project/lesspipe/versions

Attached cygport and at:

https://cygwin.com/cgit/cygwin-packages/playground/tree/lesspipe.cygport?id=43513a15e256c7203efc0ea18de8202dc16558dc

package job:

https://cygwin.com/cgi-bin2/jobs.cgi?id=8266&srcpkg=playground&user=Brian+Inglis

log at:

https://github.com/cygwin/scallywag/actions/runs/9457549487/job/26051697527

There are some test issues, some of which have been patched, some with test
data date issues, and others with filter issues which need addressed upstream.

For recent changes, see below:

2024-May-10     2.13

- added support for appimage and snap files
- respect color scheme setting of vim in vimcolor, add listing of file types
- improve xml (and html) display using the xmq binary
- fix color detection (-R) again
- support for cpio archives
- fall back to 7z for supported formats

2024-Mar-18     2.12

- improve completion for file names with special chars
- better output when using xlscat
- respect bat options from LESSCOLORIZER
- propagate lesspipe changes to lesscomplete
- don't use antiword any longer, outdated
- use 7zip instead of now outdated p7zip if available
- propagate file extension to newly created temporary files
- use again csvlook for display of csv files if available
- use csvtable for tabular display of csv files, needs Text::CSV from perl

2023-Dec-13     2.11

- fix output of archive listings when no coloring is requested
- column does not accept std input
- fix html output with html2text
- correct location of bash completion directory
- respect csv file extension

2023-Oct-05     2.10

- column does not accept -o option (BSD systems)
- respect jsx and tsx file extension

2023-Oct-03     2.09

- preferred display of csv files is through the program column
- language recognition for bat improved
- correctly recognize the -r or -R option when calling less
- support for plain zlib files(used e.g. in backuppc, pdf)
- fix jsx and tsx files often detected as html

2023-Jun-26     2.08

- protect file names in tar from being used as options
- support the device tree blob file format
- many changes for colored output
- fix template for creating a lesspipe rpm
- fix vimcolor hang due to wrong vim CLI arguments
- increase the file portion to read from STDIN to recognize its type
- do not call mediainfo on STDIN input

2023-Jan-10     2.07

- man page updates
- support for displaying mail messages
- set theme=ansi and style=plain in bat if not specified elsewhere
- correct typo in less option, recognize osascript as applescript
- better display of json files using jq
- allow for changing the output style in bat/batcat

2022-Aug-17     2.06

- remove perl storable (pst) files interpretation (security fix)
- let bat recognize language, unless explicitly requested
- call the bat colorizer with style=plain
- many changes from ShellCheck for better syntax
- run ShellCheck and test suite in GitHub Actions
- better recognition of hdf and matlab files

2022-Apr-26     2.05

- better colorize handling for bat and file names containing spaces
- fix handling of pst (perl dump) files

2022-Feb-28     2.04

- lessfilter can be in PATH or in homedir
- csv format files get displayed in tabular form
- do call ccze, mdcat only, if less accepts color seququences (-R)

2022-Feb-22     2.03

- fix colorize handling for code2color and vimcolor
- better argument parsing to detect -R option for less
- use tr to convert into lower case, test string adjustments

2022-Jan-19     2.02

- handle files names with a question mark in w3m, prefer elinks over w3m
- add again perl storable support
- add ~/.lessfilter support
- better rpm handling, documentation enhancements
- remove contrib directory, patches are partly implemented or obsolete

2022-Jan-04     2.01

- experimental zsh and bash completion for archive contents
- remove use of rpmunpack, dpkg
- minor fixes in test suite and empty file handling

2021-Dec-28     2.00

- code cleanup, minor fixes, support pygmentize with 256 color terminals

2021-Dec-22     2.00-beta

- much enhanced testsuite, can now select tests based on its number etc.
- added better bsdtar handling from the contributed bsdtar patch
- added -layout option to pdftotext
- changed code for extraction of less calling parameters
- dont engage lesspipe in pipes (LESSPIPE=|-...), if called from man and perldoc
- iconv handles most conversions from non foreign encodings
- tarcolor enhanced and renamed to archive_color, archive listings colorizations

2021-Dec-08     2.00-alpha

- complete rewrite with many fixes and enhancements.
- incompatible change: groff converts to utf8, not 'latin1' and not 'nippon'
- incompatible change: do not detect perl storable file format
- incompatible change: LESS_ADVANCED_PREPROCESSOR no longer honored
- support for growing files and calling less from a filter (LESSOPEN=|-...)
- new testsuite test.pl

--
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                -- Antoine de Saint-Exupéry
#|/bin/cygport
# lesspipe.cygport - lesspipe Cygwin package build control script definitions

NAME=lesspipe
VERSION=2.13
RELEASE=1

CATEGORY=Text
SUMMARY="less pager input file preprocessor"
DESCRIPTION="Converts many file formats to text with coloured or enhanced 
display,
so their contents or useful information about their contents can be shown.
See the less(1) man page section INPUT PREPROCESSOR.
The input filter is a bash script, which also works under zsh, and is
easily extensible for new formats.
Tab completion mechanisms for archive contents are provided for bash and zsh.
Also works with git version control, mutt mail client, vim text editor.
Can handle a wide variety of file formats, even files compressed and
contained in a hierarchy of archives, enabling users to deeply inspect
archives, and display the contents of files in archives without having
to unpack them.
Converters are checked for and used if available, including Cygwin packages:
        antiword                MS Word files
        binutils                text strings in binary files or archives
        brotli                  compressed files or archives
        bsdtar                  archive files
        bzip2                   compressed files or archives
        cabextract              MS Cabinet files
        catdoc                  MS Word files
        cpio                    archive files
        djvulibre               DjVu files
        genisoimage             ISO files or images
        ghostscript             PS files
        groff                   man pages or Unix source documents
        gzip                    compressed files or archives
        hdf5                    HDF v5 files
        id3v2                   media files
        ImageMagick             image files
        jq                      JSON data files
        libiconv                character set code page conversion
        lynx                    HTML files
        lz4                     compressed files or archives
        lzip                    compressed files or archives
        mediainfo               media files
        netcdf                  nc4 NetCDF files
        odt2txt                 OpenDocument files
        openssl                 Digital Security Certificates
        p7zip                   archive files
        perl-Image-ExifTool     media files
        poppler                 PDF files
        python39-pygments       program source code files
        rpm                     RPM files
        source-highlight        program source code files
        texlive                 TeX files
        unrtf                   RTF files
        unzip                   zip files
        util-linux              tabular data files
        w3m                     HTML files
        wordview                MS Office files
        writerperfect           MS Office files
        wv                      MS Word files
        xlsx2csv                MS Excel files
        xz                      compressed files or archives
        zstd                    compressed files or archives.
To use these, select them for install in the Cygwin Setup program."

SITE=https://www-zeuthen.desy.de/~friebel/unix
HOMEPAGE=https://github.com/wofr06/$NAME
HOMEPAGE=$SITE/lesspipe.html
SRC_URI=$SITE/less/$NAME-$VERSION.tar.gz
SRC_URI=https://github.com/wofr06/$NAME/archive/refs/tags/v$VERSION.tar.gz#/$NAME-$VERSION.tar.gz
GIT_URI=https://github.com/wofr06/$NAME/archive/refs/tags/v$VERSION.tar.gz
PATCH_URI=lesspipe-2.13-lesspipe.sh-fix-xls2csv-iconv-groff.patch

ARCH=noarch

DEPEND="bash zsh"   # supported shells
DEPEND+=" git libiconv less mutt vim perl"      # apps for tests and converters
DEPEND+=" antiword binutils brotli bsdtar bzip2 cabextract catdoc cpio"
DEPEND+=" djvulibre genisoimage ghostscript groff gzip hdf5 id3v2 ImageMagick"
DEPEND+=" jq lynx lz4 lzip mediainfo netcdf odt2txt openssl"
DEPEND+=" p7zip perl-Archive-Zip perl-Image-ExifTool poppler python39-pygments"
DEPEND+=" rpm source-highlight texlive unrtf unzip util-linux"
DEPEND+=" w3m wordview writerperfect wv xlsx2csv xz zstd"
BUILD_REQUIRES="$DEPEND"
unset DEPEND

REQUIRES="less libiconv perl-Archive-Zip"       # iconv for code page 
conversions

LICENSE=GPL-2.0-or-later
LICENSE_SPDX="SPDX-License-Identifier: $LICENSE"
# SPDX-License-Identifier: GPL-2.0-or-later
LICENSE_URI=COPYING

DIFF_EXCLUDES=$C/profile.d.sh


src_compile() {
    cd $S
#   cygautoreconf
    lndirs
    cd $B
#   cygconf
    ./configure --prefix=/usr
    cygmake
}


src_install() {
    cd $B
#   install -D "${srcdir}"/lesspipe.sh "${pkgdir}"/etc/profile.d/lesspipe.sh
#   verbose cp lesspipe.sh $C/profile.d.sh
# In bash, please preload the completion, dynamic invocation does not work
# . /usr/share/bash-completion/less_completion
# Or consider installing the file less_completion in /etc/bashcompletion.d [sic]
    dodir   /etc/bash_completion.d
    insinto /etc/bash_completion.d
    doins   less_completion
    cyginstall
    verbose rm -f $D/usr/share/bash-completion/less_completion
}


CYGWIN_MAINTAINER=Brian%20Inglis
CYGWIN_MAINTAINER_EMAIL=brian.ing...@systematicsw.ab.ca

UPSTREAM_MAINTAINER=Wolfgang%20P.%20Friebel
UPSTREAM_MAINTAINER_EMAIL=wp.frie...@gmail.com

SUBJECT=${OSTYPE^}%20Package%20$NAME%20$VERSION
MAILTO=mailto:$UPSTREAM_MAINTAINER%20%3C$UPSTREAM_MAINTAINER_EMAIL%3E\
?from=$CYGWIN_MAINTAINER%20%3C$CYGWIN_MAINTAINER_EMAIL%3E\
\&subject=$SUBJECT\&body=$SUBJECT

lesspipe-2.13: lesspipe.sh: fix issues with xls2csv, iconv, groff (man) tests

xls2csv 0.95 fails test #72 xls (old) - define function to allow options
defaults to -q 2 quote all strings: use -q 1 quote if quote|comma|space
defaults to -b '\f' ^L end of page break string - suppress -b ''

iconv 1.17 fails test #57 latin1: this also seems to fix
test #90 directory
iconv supports //TRANSLIT only with charset encoding/code page:
use lclocale charset encoding/code page instead of locale prefixed by ll_TT;
does not support inputfile "-" => /dev/stdin, invalid option flag:
change "-" to end args "--" not just null arg "" (causes other problems)
iconv 1.17 fails test #56 utf-16, iconv -f utf-XX[bl]e => -t utf-8 (with BOM)
iconv -f utf-XX => -t utf-8 (without BOM): strip be/le suffix

groff 1.23 fails test #74 as it produces escape codes: disable with -a

--- origsrc/lesspipe.sh 2024-05-10 12:48:19.000000000 -0600
+++ src/lesspipe.sh     2024-06-12 10:30:26.893356700 -0600
@@ -291,6 +291,13 @@ show () {
        fi
 }
 
+# xls2csv 0.95 fails test #72 xls (old) - define function to allow options
+# xls2csv 0.95 defaults to -q 2 quote all strings: use -q 1 quote if 
quote|comma|space
+# xls2csv 0.95 defaults to -b '\f' ^L end of page break string - suppress -b ''
+xls2csv () {
+       command -p xls2csv -q 1 -b '' "$@"
+}
+
 get_unpack_cmd () {
        fchar="${1%:*}"; fchar="${fchar#*:}"
        fcat="${1##*:}"
@@ -317,6 +324,7 @@ get_unpack_cmd () {
                        has_cmd excel2csv && cmd=(istemp excel2csv "$2") && 
return ;;
                ms-excel)
                        has_cmd in2csv && cmd=(in2csv -f xls "$2") && return
+# xls2csv 0.95 fails test #72 xls (old) - define function to allow options
                        has_cmd xls2csv && cmd=(istemp xls2csv "$2") && return 
;;
        esac
        # convert into utf8
@@ -326,9 +334,21 @@ get_unpack_cmd () {
                rep=(-c)
                trans=()
                echo ""|iconv --byte-subst - 2>/dev/null && 
rep=(--unicode-subst="$qm" --byte-subst="$qm" --widechar-subst="$qm") # MacOS
-               echo ""|iconv -f "$fchar" -t "$locale//TRANSLIT" - 2>/dev/null 
&& trans=(-t "$locale//TRANSLIT")
+# iconv 1.17 fails test #57 latin1: this also seems to fix
+# test #90 directory
+# iconv 1.17 supports //TRANSLIT only with charset encoding/code page
+# use lclocale charset encoding/code page instead of locale prefixed by ll_TT
+#              echo ""|iconv -f "$fchar" -t "$locale//TRANSLIT" - 2>/dev/null 
&& trans=(-t "$locale//TRANSLIT")
+               echo ""|iconv -f "$fchar" -t "$lclocale//TRANSLIT" - 
2>/dev/null && trans=(-t "$lclocale//TRANSLIT")
                msg "append $sep$sep to filename to view the original $fchar 
encoded file"
-               cmd=(iconv "${rep[@]}" -f "$fchar" "${trans[@]}" "$2")
+# iconv 1.17 does not support inputfile "-" => /dev/stdin, invalid option flag
+# change "-" to end args "--" not just null arg "" (causes other problems)
+               two="$2"
+               [ "$2" = "-" ] && two=--
+# iconv 1.17 fails test #56 utf-16, -f utf-XX[bl]e => -t utf-8 (with BOM)
+# -f utf-XX => -t utf-8 (without BOM): strip be/le suffix
+#              cmd=(iconv "${rep[@]}" -f "$fchar" "${trans[@]}" "$2") 
+               cmd=(iconv "${rep[@]}" -f "${fchar%[bl]e}" "${trans[@]}" "$two")
                # loop protection, just in case
                lclocale=
                return
@@ -554,7 +574,9 @@ isfinal () {
                        declare macro=andoc
                        [[ "$fext" == me ]] && macro=e
                        [[ "$fext" == ms ]] && macro=s
-                       { has_cmd groff && cmd=(groff -s -p -t -e -Tutf8 -m 
"$macro" "$1"); } ||
+# groff 1.23 fails test #74 as it produces escape codes: disable with -a
+#                      { has_cmd groff && cmd=(groff -s -p -t -e -Tutf8 -m 
"$macro" "$1"); } ||
+                       { has_cmd groff && cmd=(groff -a -s -p -t -e -Tutf8 -m 
"$macro" "$1"); } ||
                        { has_cmd mandoc && cmd=(nodash mandoc "$1"); } ||
                        { has_cmd man && cmd=(nodash man "$1"); } ;;
                rtf)

Reply via email to