aboutsummaryrefslogtreecommitdiffstats
path: root/main/cups-filters/0001-Make-textonly-conform-with-POSIX-better.patch
blob: 1653623065c8a28ec95de0fd589b53bb3875d08f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
From 1301945446a0972a0849e4b2f29e5e3b59209527 Mon Sep 17 00:00:00 2001
From: Isaac Dunham <ibid.ag@gmail.com>
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 <twaugh@redhat.com>
 ## 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