Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 May 1997 12:19:32 +0200 (MET DST)
From:      Zahemszky Gabor <zgabor@CoDe.hu>
To:        freebsd-questions@freebsd.org (FreeBSD questions)
Cc:        un_x@anchorage.net
Subject:   Re: print filter
Message-ID:  <199705271019.MAA00626@CoDe.hu>
In-Reply-To: <Pine.BSF.3.95q.970522174854.852A-100000@aak.anchorage.net> from Steve Howe at "May 22, 97 05:52:05 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> this is an "auto" bsd/dos lp filter i whipped up ...
> can anyone tell me why it prints a blank line at the
> beginning of each document (not page, document ...)?

Well, I tried it but I don't know.  Maybe your laziness about "-s, or some
bug in sh, I don't know.  Instead of if [ .. ] , try eliminating the test,
and the backtick.

if echo "$line1" | grep -q '^M' ; then ...

(Well, in 2.1.5, the -q option of grep isn't documented in the synopsis of
the grep manual, only in the long description).  Of course, this version is
cheaper with two forks/one exec (with one/zero, if [ is a builtin command in
sh), and some builtin redirection because of the `.
So I don't know, if it works, but if not, you tuned your machine's
performance, at least.  ;-)


> -------------------------------------------------------------------------
> #!/bin/sh
> #
> # simple lp text filter (BSD/DOS)
> 
> read line1
> 
> if   [ `echo $line1|grep ^M` ]; then
>         echo $line1 && cat                  && echo ^L && exit 0
> else  { echo $line1 && cat; } | sed s/$/^M/ && echo ^L && exit 0
> fi
> exit 2

Gabor
-- 
#!/bin/ksh
Z='21N16I25C25E30, 40M30E33E25T15U!' ;IFS=' ABCDEFGHIJKLMNOPQRSTUVWXYZ ';set $Z;for i { [[ $i = ? ]]&&print $i&&break;[[ $i = ??? ]]&&j=$i&&i=${i%?};typeset -i40 i=8#$i;print -n ${i#???};[[ "$j" = ??? ]]&&print -n "${j#??} "&&j=;typeset +i i;};IFS=' 0123456789 ';set $Z;X=;for i { [[ $i = , ]]&&i=2;[[ $i = ?? ]]||typeset -l i;X="$X $i";typeset +l i;};print "$X"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705271019.MAA00626>