1#!/bin/sh 2# Breed 5.6 - manages external viewers for Reed 3# Copyright (C)2019 Chris Rees <crees@FreeBSD.org> 4# Copyright (C)2001-2002 Joe Wreschnig <piman@sacredchao.net> 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# (at your option) any later version. Read the COPYING file included with 10# this program for the full text of the GNU GPL. 11 12 13program="reed" 14 15while getopts whvupbqd:j: o; do 16 case "$o" in 17 w) 18 wrap="| fold -w 75 -s" 19 ;; 20 [dj]) 21 opts="$opts -$o $OPTARG" 22 ;; 23 [?]) 24 reed -h 25 exit 1 26 ;; 27 *) 28 opts="$opts -$o" 29 ;; 30 esac 31done 32shift $(expr $OPTIND - 1) 33 34if [ "${1#:*}" = "$1" ]; then # Not a URL 35 if [ ! -f "$1" ]; then 36 echo "breed: error: No valid filenames found." 37 exit 1 38 fi 39 file=$(realpath $1) 40else 41 file=$1 42fi 43 44pipe="${wrap}| $program $opts -f $file -" 45 46file_lower=$(echo $file | tr A-Z a-z) 47 48case $file_lower in 49*.html|*.shtml|*.htm) eval lynx -dump $file $pipe;; 50*.tar.bz2|tbz) eval bunzip2 -dc $file | tar tvvf - $pipe;; 51*.tar.gz|tgz) eval gunzip -dc $file | tar tvvf - $pipe;; 52*.gz|*.z) eval gunzip -dc $file $pipe;; 53*.lha|lhz) eval lha v $file $pipe;; 54*.zip|*.jar) eval unzip -v $file $pipe;; 55*.arj) eval unarj l $file $pipe;; 56*.bz) eval bunzip -c $file $pipe;; 57*.bz2) eval bunzip2 -dc $file $pipe;; 58*.deb) eval dpkg --info $file $pipe;; 59*.doc) eval catdoc $file $pipe;; 60*.ps) eval ps2ascii $file $pipe;; 61*.pdf) eval pdftotext $file - $pipe;; 62*.rpm) eval rpm -qip $file $pipe;; 63*.tar) eval tar tvvf $file $pipe;; 64*.pdb) eval doctotext $file $pipe;; 65*.gpg|*.pgp) eval gpg --decrypt $file $pipe;; 66*) eval cat $file $pipe;; 67esac 68