"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lesspipe.sh" between
lesspipe-1.85.tar.gz and lesspipe-1.86.tar.gz

About: lesspipe is an input filter for the pager "less" to view files with binary content, compressed files, archives and files contained in archives.

lesspipe.sh  (lesspipe-1.85):lesspipe.sh  (lesspipe-1.86)
#!/bin/bash #!/bin/bash
# lesspipe.sh, a preprocessor for less (version 1.83) # lesspipe.sh, a preprocessor for less (version 1.85)
#=============================================================================== #===============================================================================
### THIS FILE IS GENERATED FROM lesspipe.sh.in, PLEASE GET THE ZIP FILE ### THIS FILE IS GENERATED FROM lesspipe.sh.in, PLEASE GET THE ZIP FILE
### from https://github.com/wofr06/lesspipe.sh/archive/lesspipe.zip ### from https://github.com/wofr06/lesspipe.sh/archive/lesspipe.zip
### AND RUN configure TO GENERATE A lesspipe.sh THAT WORKS IN YOUR ENVIRONMENT ### AND RUN configure TO GENERATE A lesspipe.sh THAT WORKS IN YOUR ENVIRONMENT
#=============================================================================== #===============================================================================
# #
# Usage: lesspipe.sh is called when the environment variable LESSOPEN is set: # Usage: lesspipe.sh is called when the environment variable LESSOPEN is set:
# LESSOPEN="|lesspipe.sh %s"; export LESSOPEN (sh like shells) # LESSOPEN="|lesspipe.sh %s"; export LESSOPEN (sh like shells)
# setenv LESSOPEN "|lesspipe.sh %s" (csh, tcsh) # setenv LESSOPEN "|lesspipe.sh %s" (csh, tcsh)
# Use the fully qualified path if lesspipe.sh is not in the search path # Use the fully qualified path if lesspipe.sh is not in the search path
skipping to change at line 51 skipping to change at line 51
cmd_exist () { cmd_exist () {
command -v "$1" > /dev/null 2>&1 && return 0 || return 1 command -v "$1" > /dev/null 2>&1 && return 0 || return 1
} }
if [[ "$LESS_ADVANCED_PREPROCESSOR" = '' ]]; then if [[ "$LESS_ADVANCED_PREPROCESSOR" = '' ]]; then
NOL_A_P=_NO_L_A_P NOL_A_P=_NO_L_A_P
fi fi
filecmd() { filecmd() {
file -L -s "$@" file -L -s "$@"
file -L -s -i "$@" 2> /dev/null | sed -n 's/.*charset=/;/p' | tr a-z A-Z file -L -s -i "$@" 2> /dev/null | sed -n 's/.*charset=/;/p' | tr [:lower:] [:u pper:]
} }
TMPDIR=${TMPDIR:-/tmp} TMPDIR=${TMPDIR:-/tmp}
sep=: # file name separator sep=: # file name separator
altsep== # alternate separator character altsep== # alternate separator character
if [[ -e "$1" && "$1" = *$sep* || "$1" = *$altsep ]]; then if [[ -e "$1" && "$1" = *$sep* || "$1" = *$sep*$altsep* ]]; then
sep=$altsep sep=$altsep
xxx="${1%=}" xxx="${1%=}"
set "$xxx" set "$xxx"
fi fi
if cmd_exist mktemp; then tmpdir="$TMPDIR"/lesspipe."$RANDOM"
tmpdir=$(mktemp -d "$TMPDIR/lesspipe.XXXXXXXXXX") mkdir "$tmpdir"
nexttmp () { nexttmp () {
# nexttmp -d returns a directory new="$tmpdir/lesspipe.$RANDOM"
mktemp "$1" "${tmpdir}/XXXXXXXX" [[ "$1" = -d ]] && mkdir "$new"
} echo "$new"
else }
tmpdir="$TMPDIR"/lesspipe."$RANDOM"
mkdir "$tmpdir"
nexttmp () {
new="$tmpdir/lesspipe.$RANDOM"
[[ "$1" = -d ]] && mkdir "$new"
echo "$new"
}
fi
[[ -d "$tmpdir" ]] || exit 1 [[ -d "$tmpdir" ]] || exit 1
trap "rm -rf '$tmpdir'" 0 trap "rm -rf '$tmpdir'" 0
trap - PIPE trap - PIPE
unset iconv unset iconv
iconv() { iconv() {
if [[ -z "$iconv" ]]; then if [[ -z "$iconv" ]]; then
arg=$(printf "%s$(command iconv --help 2>/dev/null | \ arg=$(printf "%s$(command iconv --help 2>/dev/null | \
sed -n 's/.*\(--.*-subst=\)\(FORMATSTRING\).*/\1\\033[7m?\\033[m/p' | \ sed -n 's/.*\(--.*-subst=\)\(FORMATSTRING\).*/\1\\033[7m?\\033[m/p' | \
tr \\n ' ')") tr \\n ' ')")
skipping to change at line 115 skipping to change at line 106
echo "==> $@" echo "==> $@"
} }
filetype () { filetype () {
# wrapper for 'file' command # wrapper for 'file' command
typeset name typeset name
name="$1" name="$1"
if [[ "$1" = - ]]; then if [[ "$1" = - ]]; then
name="$filen" name="$filen"
fi fi
# ifdef brotli
if [[ ("$name" = *.br || "$name" = *.bro || "$name" = *.tbr) ]]; then if [[ ("$name" = *.br || "$name" = *.bro || "$name" = *.tbr) ]]; then
# In current format, brotli can only be detected by extension # In current format, brotli can only be detected by extension
echo " brotli compressed data" echo " brotli compressed data"
return return
fi fi
# endif
if [[ "$1" = - ]]; then if [[ "$1" = - ]]; then
dd bs=40000 count=1 > "$tmpdir/file" 2>/dev/null dd bs=40000 count=1 > "$tmpdir/file" 2>/dev/null
set "$tmpdir/file" "$2" set "$tmpdir/file" "$2"
fi fi
typeset return typeset return
# file -b not supported by all versions of 'file' # file -b not supported by all versions of 'file'
type="$(filecmd "$1" | cut -d : -f 2- )" type="$(filecmd "$1" | cut -d : -f 2- )"
if [[ "$type" = " empty" ]]; then if [[ "$type" = " empty" ]]; then
# exit if file returns "empty" (e.g., with "less archive:nonexisting_file") # exit if file returns "empty" (e.g., with "less archive:nonexisting_file")
exit 1 exit 1
# Open Office # Open Office
elif [[ "$type" = *OpenDocument\ Text* ]]; then elif [[ "$type" = *OpenDocument\ Text* ]]; then
return=" OpenDocument Text" return=" OpenDocument Text"
elif [[ "$type" = *OpenDocument\ * || "$type" = *OpenOffice\.org\ 1\.x\ * ]]; then elif [[ "$type" = *OpenDocument\ * || "$type" = *OpenOffice\.org\ 1\.x\ * ]]; then
return=" OpenDocument" return=" OpenDocument"
# Microsoft Office < 2007 # Microsoft Office < 2007
elif [[ "$type" = *Microsoft\ Office\ Document* && ("$name" = *.do[st]) ]] || elif [[ "$type" = *Microsoft\ Office\ Document* && ("$name" = *.do[st]) ]] ||
[[ "$type" = *Microsoft\ Office\ Word* ]]; then [[ "$type" = *Microsoft\ Office\ Word* ]]; then
return=" Microsoft Word Document" return=" Microsoft Word Document"
elif [[ "$type" = *Microsoft\ Office\ Document* && ("$name" = *.pp[st]) ]] || elif [[ "$type" = *Microsoft\ Office\ Document* && ("$name" = *.pp[st]) ]] ||
[[ "$type" = *Microsoft\ Office\ PowerPoint* ]]; then [[ "$type" = *Microsoft\ Office\ PowerPoint* ]]; then
return=" Microsoft PowerPoint Document" return=" Microsoft PowerPoint Document"
elif [[ "$type" = *Microsoft\ Office\ Document* && ("$name" = *.xl[mst]) ]] || elif [[ "$type" = *Microsoft\ Office\ Document* && ("$name" = *.xl[mst]) ]] ||
[[ "$type" = *Microsoft\ Excel* ]]; then [[ "$type" = *Microsoft\ Excel* ]]; then
return=" Microsoft Excel Document" return=" Microsoft Excel Document"
elif [[ "$type" = *Microsoft\ Office\ Document* ]]; then elif [[ "$type" = *Microsoft\ Office\ Document* || "$type" = *Composite\ Documen
return=" Microsoft Office Document" t\ File\ V2* ]]; then
# Microsoft Office >= 2007 return=" Microsoft Office Document"
elif [[ ("$type" = *Zip\ archive* || "$type" = Microsoft\ OOXML) && "$name" = # Microsoft Office >= 2007
*.do[ct][xm] ]] || elif [[ ("$type" = *Zip\ archive* || "$type" = Microsoft\ OOXML) && "$name" = *
[[ "$type" = *Microsoft\ Word\ 2007* ]]; then .do[ct][xm] ]] ||
return=" Microsoft Word 2007+" [[ "$type" = *Microsoft\ Word\ 2007* ]]; then
return=" Microsoft Word 2007+"
elif [[ ("$type" = *Zip\ archive* || "$type" = Microsoft\ OOXML) && "$name" = *.pp[st][xm] ]] || elif [[ ("$type" = *Zip\ archive* || "$type" = Microsoft\ OOXML) && "$name" = *.pp[st][xm] ]] ||
[[ "$type" = *Microsoft\ PowerPoint\ 2007* ]]; then [[ "$type" = *Microsoft\ PowerPoint\ 2007* ]]; then
return=" Microsoft PowerPoint 2007+" return=" Microsoft PowerPoint 2007+"
elif [[ ("$type" = *Zip\ archive* || "$type" = Microsoft\ OOXML) && "$name" = elif [[ ("$type" = *Zip\ archive* || "$type" = Microsoft\ OOXML) && "$name" = *
*.xl[st][xmb] ]] || .xl[st][xmb] ]] ||
[[ "$type" = *Microsoft\ Excel\ 2007* ]]; then [[ "$type" = *Microsoft\ Excel\ 2007* ]]; then
return=" Microsoft Excel 2007+" return=" Microsoft Excel 2007+"
elif [[ "$type" = *Zip\ archive* || "$type" = Microsoft\ OOXML ]] || elif [[ "$type" = Microsoft\ OOXML ]] ||
[[ "$type" = *Microsoft\ *\ 2007* ]]; then [[ "$type" = *Microsoft\ *\ 2007* ]]; then
return=" Microsoft Office 2007" return=" Microsoft Office 2007"
# MP3 # MP3
elif [[ "$type" = *MPEG\ *layer\ 3\ audio* || "$type" = *MPEG\ *layer\ III* || elif [[ "$type" = *MPEG\ *layer\ 3\ audio* || "$type" = *MPEG\ *layer\ III* || "
"$type" = *mp3\ file* || "$type" = *MP3* ]]; then $type" = *mp3\ file* || "$type" = *MP3* ]]; then
return="mp3" return="mp3"
# Compressed Archives # Compressed Archives
elif [[ "$type" != *lzip\ compressed* && ("$name" = *.lzma || "$name" = *.tlz) elif [[ "$type" != *lzip\ compressed* && ("$name" = *.lzma || "$name" = *.tlz) ]
]]; then ]; then
return=" LZMA compressed data" return=" LZMA compressed data"
elif [[ ("$type" = *Zip* || "$type" = *ZIP*) && ("$name" = *.jar || "$name" = elif [[ ("$type" = *Zip* || "$type" = *ZIP* || "$type" = *JAR*) && ("$name" = *.
*.xpi) ]]; then jar || "$name" = *.xpi) ]]; then
return=" Zip compressed Jar archive" return=" Zip compressed Jar archive"
elif [[ "$type" = *Hierarchical\ Data\ Format* && ("$name" = *.nc4) ]]; then elif [[ "$type" = *Hierarchical\ Data\ Format* && ("$name" = *.nc4) ]]; then
return=" NetCDF Data Format data" return=" NetCDF Data Format data"
# Sometimes a BSD makefile is identified as "troff or preprocessor input # Sometimes a BSD makefile is identified as "troff or preprocessor input
# text" probably due to its ".if" style directives. # text" probably due to its ".if" style directives.
elif [[ "$type" = *roff\ *,* && ("$name" = */[Mm]akefile || "$name" = */[Mm]ak elif [[ "$type" = *roff\ *,* && ("$name" = */[Mm]akefile || "$name" = */[Mm]akef
efile.* || "$name" = */BSDmakefile || "$name" = *.mk) ]]; then ile.* || "$name" = */BSDmakefile || "$name" = *.mk) ]]; then
return=" BSD makefile script,${type#*,}}" return=" BSD makefile script,${type#*,}}"
# Correct HTML Detection # Correct HTML Detection
elif [[ ("$type" = *HTML* || "$type" = *ASCII*) && "$name" = *xml ]]; then elif [[ ("$type" = *HTML* || "$type" = *ASCII*) && "$name" = *xml ]]; then
return=" XML document text" return=" XML document text"
elif [[ "$type" = *XML* && "$name" = *html ]]; then elif [[ "$type" = *XML* && "$name" = *html ]]; then
return=" HTML document text" return=" HTML document text"
fi fi
if [[ -n "$return" ]]; then if [[ -n "$return" ]]; then
echo "$return" echo "$return"
return return
elif [[ -n "$type" ]]; then fi
echo "$type"
return
fi
# file -b not supported by all versions of 'file' mime="$(file -i "$1" | cut -d : -f 2-)"
mime="$(file -i "$1" | cut -d : -f 2-)" if [[ "$mime" = \ text/* ]]; then
if [[ "$mime" = \ text/* ]]; then return="text"
return="text" elif [[ "$mime" = \ image/* ]]; then
elif [[ "$mime" = \ image/* ]]; then return="image"
return="image" elif [[ "$mime" = \ audio/* ]]; then
elif [[ "$mime" = \ audio/* ]]; then return="audio"
return="audio" elif [[ "$mime" = \ video/* ]]; then
elif [[ "$mime" = \ video/* ]]; then return="video"
return="video" fi
fi
if [[ -n "$return" ]]; then if [[ -n "$return" ]]; then
echo "$return" echo "$return"
return return
fi fi
if [[ -n "$mime" ]]; then if [[ -n "$mime" ]]; then
return="$mime" return="$mime"
else else
return="" return=""
fi fi
echo "$return" echo "$return"
} }
show () { show () {
file1="${1%%$sep*}" file1="${1%%$sep*}"
rest1="${1#$file1}" rest1="${1#$file1}"
while [[ "$rest1" = ::* ]]; do while [[ "$rest1" = ::* ]]; do
if [[ "$rest1" = "::" ]]; then if [[ "$rest1" = "::" ]]; then
break break
else else
rest1="${rest1#$sep$sep}" rest1="${rest1#$sep$sep}"
skipping to change at line 584 skipping to change at line 573
cmd_string="zstd -dcqM1073741824 -" cmd_string="zstd -dcqM1073741824 -"
elif [[ ("$1" == *br || "$1" == *bro) ]]; then elif [[ ("$1" == *br || "$1" == *bro) ]]; then
cmd_string="brotli -dc -" cmd_string="brotli -dc -"
elif [[ "$1" == *lz4 ]]; then elif [[ "$1" == *lz4 ]]; then
cmd_string="lz4 -dcq -" cmd_string="lz4 -dcq -"
fi fi
echo "$cmd_string" echo "$cmd_string"
} }
isfinal() { isfinal() {
# color requires -r or -R when calling less
typeset COLOR
if [[ $(tput colors) -ge 8 && ("$LESS" = *-*r* || "$LESS" = *-*R*) ]]; then
COLOR="--color=always"
else
COLOR="--color=auto"
fi
typeset t typeset t
if [[ $3 = $sep$sep ]]; then if [[ $3 = $sep$sep ]]; then
cat "$2" cat "$2"
return return
elif [[ $3 = $sep* ]]; then elif [[ $3 = $sep* ]]; then
if [[ $3 = "$sep" ]]; then if [[ $3 = "$sep" ]]; then
msg "append :. or :<filetype> to activate syntax highlighting" msg "append :. or :<filetype> to activate syntax highlighting"
else else
lang=${3#$sep} lang=${3#$sep}
lang="-l${lang#.}" lang="-l${lang#.}"
lang=${lang%%-l } lang=${lang%%-l }
if cmd_exist code2color; then if cmd_exist bat; then
code2color $PPID ${in_file:+"$in_file"} "$lang" "$2" if [[ "$lang" = "-l" ]]; then
if [[ $? = 0 ]]; then bat $COLOR "$2"
return else
bat $COLOR "$lang" "$2"
fi fi
[[ $? = 0 ]] && return
elif cmd_exist batcat; then
if [[ "$lang" = "-l" ]]; then
batcat $COLOR "$2"
else
batcat $COLOR "$lang" "$2"
fi
[[ $? = 0 ]] && return
elif cmd_exist code2color; then
code2color $PPID ${in_file:+"$in_file"} "$lang" "$2"
[[ $? = 0 ]] && return
fi fi
fi fi
cat "$2" cat "$2"
return return
fi fi
# color requires -r or -R when calling less
typeset COLOR
if [[ $(tput colors) -ge 8 && ("$LESS" = *-*r* || "$LESS" = *-*R*) ]]; then
COLOR="--color=always"
fi
lang="$(echo $LANG | tr '[:upper:]' '[:lower:]')" lang="$(echo $LANG | tr '[:upper:]' '[:lower:]')"
if [[ "$1" = *No\ such* ]]; then if [[ "$1" = *No\ such* ]]; then
exit 1 exit 1
elif [[ "$1" = *directory* ]]; then elif [[ "$1" = *directory* ]]; then
cmd=(ls -lA $COLOR "$2") cmd=(ls -lA $COLOR "$2")
if ! ls $COLOR > /dev/null 2>&1; then if ! ls $COLOR > /dev/null 2>&1; then
cmd=(ls -lA -G "$2") cmd=(ls -lA -G "$2")
if ! ls -lA -G > /dev/null 2>&1; then if ! ls -lA -G > /dev/null 2>&1; then
cmd=(ls -lA "$2") cmd=(ls -lA "$2")
fi fi
fi fi
skipping to change at line 693 skipping to change at line 696
# do not display all perl text containing pod using perldoc # do not display all perl text containing pod using perldoc
#elif [[ "$1" = *Perl\ POD\ document\ text* || "$1" = *Perl5\ module\ source\ text* ]]; then #elif [[ "$1" = *Perl\ POD\ document\ text* || "$1" = *Perl5\ module\ source\ text* ]]; then
elif [[ "$1" = *Perl\ POD\ document\ text$NOL_A_P* ]] && cmd_exist perldoc; th en elif [[ "$1" = *Perl\ POD\ document\ text$NOL_A_P* ]] && cmd_exist perldoc; th en
msg "append $sep to filename to view the perl source" msg "append $sep to filename to view the perl source"
istemp perldoc "$2" istemp perldoc "$2"
elif [[ "$1" = *\ script* ]]; then elif [[ "$1" = *\ script* ]]; then
set "plain text" "$2" set "plain text" "$2"
elif [[ "$1" = *text\ executable* ]]; then elif [[ "$1" = *text\ executable* ]]; then
set "plain text" "$2" set "plain text" "$2"
elif [[ "$1" = *PostScript$NOL_A_P* ]]; then elif [[ "$1" = *PostScript$NOL_A_P* ]]; then
if cmd_exist pstotext; then if cmd_exist ps2ascii; then
msg "append $sep to filename to view the postscript file" msg "append $sep to filename to view the postscript file"
nodash pstotext "$2" nodash ps2ascii "$2"
elif cmd_exist ps2ascii; then
msg "append $sep to filename to view the postscript file"
istemp ps2ascii "$2"
else
msg "install pstotext or ps2ascii to view a textual representation of the
file contents"
fi fi
elif [[ "$1" = *executable* ]]; then elif [[ "$1" = *executable* ]]; then
msg "append $sep to filename to view the raw file" msg "append $sep to filename to view the raw file"
nodash strings "$2" nodash strings "$2"
elif [[ "$1" = *\ ar\ archive* ]]; then elif [[ "$1" = *\ ar\ archive* ]]; then
msg "use library${sep}contained_file to view a file in the archive" msg "use library${sep}contained_file to view a file in the archive"
istemp "ar vt" "$2" istemp "ar vt" "$2"
elif [[ "$1" = *shared* ]] && cmd_exist nm; then elif [[ "$1" = *shared* ]] && cmd_exist nm; then
msg "This is a dynamic library, showing the output of nm" msg "This is a dynamic library, showing the output of nm"
istemp nm "$2" istemp nm "$2"
skipping to change at line 775 skipping to change at line 773
fi fi
elif [[ "$1" = *[Cc]abinet* ]] && cmd_exist cabextract; then elif [[ "$1" = *[Cc]abinet* ]] && cmd_exist cabextract; then
msg "use cab_file${sep}contained_file to view a file in the cabinet" msg "use cab_file${sep}contained_file to view a file in the cabinet"
istemp "cabextract -l" "$2" istemp "cabextract -l" "$2"
elif [[ "$1" = *\ DVI* ]] && cmd_exist dvi2tty; then elif [[ "$1" = *\ DVI* ]] && cmd_exist dvi2tty; then
msg "append $sep to filename to view the raw DVI file" msg "append $sep to filename to view the raw DVI file"
isdvi "$2" isdvi "$2"
elif [[ "$PARSEHTML" = yes && "$1" = *HTML$NOL_A_P* ]]; then elif [[ "$PARSEHTML" = yes && "$1" = *HTML$NOL_A_P* ]]; then
msg "append $sep to filename to view the HTML source" msg "append $sep to filename to view the HTML source"
parsehtml "$2" parsehtml "$2"
elif [[ "$1" = *PDF* ]] && cmd_exist pdftotext; then elif [[ "$1" = *pdf* ]] && cmd_exist pdftotext; then
if [[ "$PARSEHTML" = yes ]]; then if [[ "$PARSEHTML" = yes ]]; then
msg "append $sep to filename to view the PDF source" msg "append $sep to filename to view the PDF source"
istemp "pdftotext -htmlmeta" "$2" - | parsehtml - istemp "pdftotext -htmlmeta -nopgbrk -q --" "$2" - | parsehtml -
else else
msg "append $sep to filename to view the PDF source" msg "append $sep to filename to view the PDF source"
istemp pdftotext "$2" - istemp pdftotext -nopgbrk -q -- "$2" -
fi fi
elif [[ "$PARSEHTML" = yes && "$1" = *PDF* ]] && cmd_exist pdftohtml; then elif [[ "$PARSEHTML" = yes && "$1" = *pdf* ]] && cmd_exist pdftohtml; then
msg "append $sep to filename to view the PDF source" msg "append $sep to filename to view the PDF source"
t=$(nexttmp) t=$(nexttmp)
cat "$2" > "$t"; pdftohtml -stdout "$t" | parsehtml - cat "$2" > "$t"; pdftohtml -i -noframes -nodrm -enc UTF-8 -stdout "$t" | par
elif [[ "$1" = *PDF* ]] && cmd_exist pdfinfo; then sehtml -
elif [[ "$1" = *pdf* ]] && cmd_exist pdfinfo; then
msg "append $sep to filename to view the PDF source" msg "append $sep to filename to view the PDF source"
istemp pdfinfo "$2" istemp pdfinfo "$2"
elif [[ "$1" = *Hierarchical\ Data\ Format* ]] && cmd_exist h5dump; then elif [[ "$1" = *Hierarchical\ Data\ Format* ]] && cmd_exist h5dump; then
istemp h5dump "$2" istemp h5dump "$2"
elif [[ "$1" = *NetCDF* || "$1" = *Hierarchical\ Data\ Format* ]] && cmd_exist ncdump; then elif [[ "$1" = *NetCDF* || "$1" = *Hierarchical\ Data\ Format* ]] && cmd_exist ncdump; then
istemp ncdump "$2" istemp ncdump "$2"
elif [[ "$1" = *Matlab\ v[0-9.]*\ mat-file* ]] && cmd_exist matdump; then elif [[ "$1" = *Matlab\ v[0-9.]*\ mat-file* ]] && cmd_exist matdump; then
msg "append $sep to filename to view the raw data" msg "append $sep to filename to view the raw data"
matdump -d "$2" matdump -d "$2"
elif [[ "$1" = *DjVu* ]] && cmd_exist djvutxt; then elif [[ "$1" = *DjVu* ]] && cmd_exist djvutxt; then
skipping to change at line 811 skipping to change at line 809
if cmd_exist docx2txt.pl; then if cmd_exist docx2txt.pl; then
msg "append $sep to filename to view the raw word document" msg "append $sep to filename to view the raw word document"
docx2txt.pl "$2" - docx2txt.pl "$2" -
else else
msg "install docx2txt.pl to view human readable text" msg "install docx2txt.pl to view human readable text"
cat "$2" cat "$2"
fi fi
elif [[ "$1" = *OpenDocument\ Text* ]]; then elif [[ "$1" = *OpenDocument\ Text* ]]; then
if cmd_exist odt2txt; then if cmd_exist odt2txt; then
msg "append $sep to filename to view the raw word document" msg "append $sep to filename to view the raw word document"
odt2txt "$2" istemp odt2txt "$2"
else else
msg "install odt2txt to view human readable text" msg "install odt2txt to view human readable text"
cat "$2" cat "$2"
fi fi
elif [[ "$1" = *Microsoft\ Word\ 2007* ]]; then elif [[ "$1" = *Microsoft\ Word\ 2007* ]]; then
if cmd_exist pandoc; then if cmd_exist pandoc; then
msg "append $sep to filename to view the raw word document" msg "append $sep to filename to view the raw word document"
pandoc --from=docx --to=plain "$2" pandoc --from=docx --to=plain "$2"
else else
msg "install pandoc to view human readable text" msg "install pandoc to view human readable text"
skipping to change at line 840 skipping to change at line 838
cat "$2" cat "$2"
fi fi
elif [[ "$1" = *EPUB\ document* ]]; then elif [[ "$1" = *EPUB\ document* ]]; then
if cmd_exist pandoc; then if cmd_exist pandoc; then
msg "append $sep to filename to view the raw word document" msg "append $sep to filename to view the raw word document"
pandoc --from=epub --to=plain "$2" pandoc --from=epub --to=plain "$2"
else else
msg "install pandoc to view human readable text" msg "install pandoc to view human readable text"
cat "$2" cat "$2"
fi fi
elif [[ "$1" = *Microsoft\ Word\ Document* ]] && cmd_exist wvText; then elif [[ "$1" = *Microsoft\ Word\ Document* || "$1" = *Microsoft\ Office\ Docum ent* ]] && cmd_exist wvText; then
msg "append $sep to filename to view the raw word document" msg "append $sep to filename to view the raw word document"
wvText "$2" /dev/stdout wvText "$2" /dev/stdout
elif [[ "$1" = *Microsoft\ Word\ Document* ]]; then elif [[ "$1" = *Microsoft\ Word\ Document* || "$1" = *Microsoft\ Office\ Docum ent* ]]; then
if cmd_exist antiword; then if cmd_exist antiword; then
msg "append $sep to filename to view the raw word document" msg "append $sep to filename to view the raw word document"
antiword "$2" antiword "$2"
elif cmd_exist catdoc; then elif cmd_exist catdoc; then
msg "append $sep to filename to view the raw word document" msg "append $sep to filename to view the raw word document"
catdoc "$2" catdoc "$2"
else else
msg "install antiword or catdoc to view human readable text" msg "install antiword or catdoc to view human readable text"
cat "$2" cat "$2"
fi fi
skipping to change at line 927 skipping to change at line 925
if [[ "$2" != - ]]; then if [[ "$2" != - ]]; then
msg "append $sep to filename to view the raw data" msg "append $sep to filename to view the raw data"
isoinfo -d -i "$2" isoinfo -d -i "$2"
joliet=$(isoinfo -d -i "$2" | grep -E '^Joliet'|cut -c1) joliet=$(isoinfo -d -i "$2" | grep -E '^Joliet'|cut -c1)
echo "================================= Content ========================== ============" echo "================================= Content ========================== ============"
isoinfo -lR"$joliet" -i "$2" isoinfo -lR"$joliet" -i "$2"
fi fi
elif [[ "$1" = *bill\ of\ materials* ]] && cmd_exist lsbom; then elif [[ "$1" = *bill\ of\ materials* ]] && cmd_exist lsbom; then
msg "append $sep to filename to view the raw data" msg "append $sep to filename to view the raw data"
lsbom -p MUGsf "$2" lsbom -p MUGsf "$2"
elif [[ "$1" = *perl\ Storable$NOL_A_P* ]]; then elif [[ "$1" = *perl.?[sS]torable$NOL_A_P* ]]; then
msg "append $sep to filename to view the raw data" msg "append $sep to filename to view the raw data"
perl -MStorable=retrieve -MData::Dumper -e '$Data::Dumper::Indent=1;print Du mper retrieve shift' "$2" perl -MStorable=retrieve -MData::Dumper -e '$Data::Dumper::Indent=1;print Du mper retrieve shift' "$2"
elif [[ "$1" = *UTF-8$NOL_A_P* && "$lang" != *utf-8* ]] && cmd_exist iconv -c; then elif [[ "$1" = *UTF-8$NOL_A_P* && "$lang" != *utf-8* ]] && cmd_exist iconv -c; then
iconv -c -f UTF-8 "$2" iconv -c -f UTF-8 "$2"
elif [[ "$1" = *UTF-16$NOL_A_P* && "$lang" != *utf-16* ]] && cmd_exist iconv - c; then elif [[ "$1" = *UTF-16$NOL_A_P* && "$lang" != *utf-16* ]] && cmd_exist iconv - c; then
iconv -c -f UTF-16 "$2" iconv -c -f UTF-16 "$2"
elif [[ "$1" = *ISO-8859$NOL_A_P* && "$lang" != *iso-8859-1* ]] && cmd_exist i conv -c; then elif [[ "$1" = *ISO-8859$NOL_A_P* && "$lang" != *iso-8859-1* ]] && cmd_exist i conv -c; then
iconv -c -f ISO-8859-1 "$2" iconv -c -f ISO-8859-1 "$2"
elif [[ "$1" = *GPG\ encrypted\ data* || "$1" = *PGP\ *ncrypted* ]] && cmd_exi st gpg; then elif [[ "$1" = *GPG\ encrypted\ data* || "$1" = *PGP\ *ncrypted* ]] && cmd_exi st gpg; then
msg "append $sep to filename to view the encrypted file" msg "append $sep to filename to view the encrypted file"
skipping to change at line 974 skipping to change at line 972
elif cmd_exist mp3info; then elif cmd_exist mp3info; then
msg "append $sep to filename to view the raw data" msg "append $sep to filename to view the raw data"
mp3info "$2" mp3info "$2"
fi fi
elif [[ "$1" = "image" || "$1" = "mp3" || "$1" = "audio" || "$1" = "video" ]] && cmd_exist mediainfo; then elif [[ "$1" = "image" || "$1" = "mp3" || "$1" = "audio" || "$1" = "video" ]] && cmd_exist mediainfo; then
msg "append $sep to filename to view the raw data" msg "append $sep to filename to view the raw data"
mediainfo --Full "$2" mediainfo --Full "$2"
elif [[ "$1" = "image" || "$1" = "mp3" || "$1" = "audio" || "$1" = "video" ]] && cmd_exist exiftool; then elif [[ "$1" = "image" || "$1" = "mp3" || "$1" = "audio" || "$1" = "video" ]] && cmd_exist exiftool; then
msg "append $sep to filename to view the raw data" msg "append $sep to filename to view the raw data"
exiftool "$2" exiftool "$2"
elif [[ "$1" = *text* ]]; then fi
if [[ "$2" = *.md || "$2" = *.MD || "$2" = *.mkd || "$2" = *.markdown ]] &&
cmd_exist mdcat; then if [[ "$1" = *text* ]]; then
mdcat "$2" if [[ "$2" != '-' ]]; then
elif [[ "$2" = *.log ]] && if [[ "$1" = *ASCII\ text* || "$1" = *Unicode\ text* ]]; then
cmd_exist ccze; then cat "$2"
cat "$2" | ccze -A elif [[ "$2" = *.md || "$2" = *.MD || "$2" = *.mkd || "$2" = *.markdown ]]
&&
cmd_exist mdcat; then
mdcat "$2"
elif [[ "$2" = *.log ]] &&
cmd_exist ccze; then
cat "$2" | ccze -A
# ifdef perl
elif cmd_exist code2color; then
code2color $PPID ${in_file:+"$in_file"} "$2"
#endif
elif cmd_exist bat; then
bat $COLOR "$2"
elif cmd_exist batcat; then
batcat $COLOR "$2"
else
cat "$2"
fi
else else
cat "$2" # if [[ "$2" = - ]]; then
fi if [[ "$1" = *ASCII\ text* || "$1" = *Unicode\ text* ]]; then
else cat
if [[ "$2" = - ]]; then # ifdef perl
cat elif cmd_exist code2color; then
else cmd_exist code2color && code2color $PPID ${in_file:+"$in_file"} "$2"
code2color $PPID ${in_file:+"$in_file"} "$2" && #endif
return elif cmd_exist bat; then
fi bat $COLOR "$2"
elif cmd_exist batcat; then
batcat $COLOR "$2"
else
cat
fi
[[ $? = 0 ]] && return
fi
fi fi
} }
IFS=$sep a="$@" IFS=$sep a="$@"
IFS=' ' IFS=' '
if [[ "$a" = "" ]]; then if [[ "$a" = "" ]]; then
if [[ "$0" != /* ]]; then if [[ "$0" != /* ]]; then
pat=$(pwd)/ pat=$(pwd)/
fi fi
if [[ "$SHELL" = *csh ]]; then if [[ "$SHELL" = *csh ]]; then
 End of changes. 35 change blocks. 
141 lines changed or deleted 164 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)