From 1301945446a0972a0849e4b2f29e5e3b59209527 Mon Sep 17 00:00:00 2001 From: Isaac Dunham Date: Thu, 14 Jan 2016 06:51:07 -0800 Subject: [PATCH] Make textonly conform with POSIX better. echo -ne was the only thing that could be expected to not work on every shell. --- filter/textonly | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/filter/textonly b/filter/textonly index dd55a9d..630cb8f 100644 --- a/filter/textonly +++ b/filter/textonly @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh ## Copyright (C) 2003-2006 Red Hat, Inc. ## Copyright (C) 2003-2006 Tim Waugh ## Changed on 2007/05/17, Opher Shachar, LADPC Ltd. @@ -64,7 +64,7 @@ if [[ "$PR" ]]; then (( pl > pu )) && continue # Loop reading pages until at or over lower page of subrange. - while read -d `echo -ne '\f'` -r; do + while read -d `printf '\f'` -r; do (( pagenum++ )) (( pagenum == pl )) && break done @@ -78,15 +78,15 @@ if [[ "$PR" ]]; then if (( pagenum == pl )); then echo -n "${REPLY}" >>"$TMPFILE2" # If EOF then page has no final FF - [[ ! "$EOF" ]] && echo -ne '\f' >>"$TMPFILE2" + [[ ! "$EOF" ]] && printf '\f' >>"$TMPFILE2" echo "PAGE: $pagenum $COPIES" >&2 fi [[ "$EOF" ]] && break # Is the current subrange a single page? (( pagenum == pu )) && continue - while read -d `echo -ne '\f'` -r; do + while read -d `printf '\f'` -r; do (( pagenum++ )) - echo -ne "${REPLY}\f" >>"$TMPFILE2" + printf "${REPLY}\f" >>"$TMPFILE2" echo "PAGE: $pagenum $COPIES" >&2 (( pagenum == pu )) && break done @@ -103,18 +103,18 @@ if [[ "$PR" ]]; then } <"$TMPFILE" else TMPFILE2="$TMPFILE" - pc=$(grep -co `echo -ne '\f'` "$TMPFILE2") + pc=$(grep -co `printf '\f'` "$TMPFILE2") pc=$(( pc * $COPIES )) echo "PAGE: $pc" >&2 fi while [ "$COPIES" -gt 0 ]; do # Just translate LF->CRLF at the moment, until the PPD has options added. - sed -e 's/$/'`echo -ne '\r'`'/g' "$TMPFILE2" + sed -e 's/$/'`printf '\r'`'/g' "$TMPFILE2" if [ "$SENDFF" == "True" ] then - echo -ne \\014 + printf \\014 fi COPIES=$(($COPIES - 1)) -- 2.7.0