summaryrefslogtreecommitdiffstats
path: root/system/epson-printer-utility/fixrm
diff options
context:
space:
mode:
Diffstat (limited to 'system/epson-printer-utility/fixrm')
-rw-r--r--system/epson-printer-utility/fixrm30
1 files changed, 30 insertions, 0 deletions
diff --git a/system/epson-printer-utility/fixrm b/system/epson-printer-utility/fixrm
new file mode 100644
index 0000000000..e1c5c21315
--- /dev/null
+++ b/system/epson-printer-utility/fixrm
@@ -0,0 +1,30 @@
+#!/bin/sh
+#fixrm is a little script to limit the items on each line so the line
+#is less than 72 characters. it is used by the maintainer when creating
+#the README.models file for this package, and for the epson-inkjet-printer-escpr2
+#slackbuild. It takes the list posted on a single long first line, and spreads
+#them over as many lines as needed.
+#
+#paste the list from the epson website into an empty README.models and run this
+#script in the same directory
+
+FNAME="README.models"
+MAXLEN=${MAXLEN:-72}
+#make sure MAXLEN is a integer bigger than 39
+MAXLEN=`echo $MAXLEN|awk '($1<40) {print "40"} (int($1)>39) {print int($1) }'`
+if [ -e $FNAME ]&&[ `cat $FNAME|head -n1|awk '{print length($0)}'` -gt $MAXLEN ]; then
+ #only do something if the file exists, and thefirst line is longer than it
+ #should be.
+ TMPFILE=rmtmp
+ mv README.models $TMPFILE
+ cat $TMPFILE|awk -v mlen="$MAXLEN" -F', ' 'BEGIN{curline="";mlen=mlen-2}
+{ for (i=1;i<=NF; i++)
+ { { n=0; l=length(curline)+length($i) }
+ if (i==1) {curline=$i; n=1}
+ if (l<mlen && i>1) { curline=curline ", " $i; n=1}
+ if (n==0) {print curline; curline=$i }
+ }
+ if (length(curline)>0) {print curline; curline=""}
+}'>README.models
+ rm $TMPFILE
+fi