annotate tools/rdock/bin/to_unix @ 2:0faa03a92843 draft default tip

Uploaded
author dzesikah
date Fri, 26 Aug 2016 10:19:49 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
1 #! /bin/sh -e
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
2 #Tag 1538
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
3 #
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
4 # convert a DOS ASCII file to a UNIX ASCII file by removing trailing ^M at the
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
5 # end of each line and ^Z at the end of the file
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
6
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
7 #DM 23 Oct 2000 - tmp file in current directory, not /tmp
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
8 #TMPFILE=/tmp/to_unix$$
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
9 TMPFILE=to_unix$$
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
10
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
11 if [ $# -gt 2 ]
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
12 then
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
13 echo "usage: to_unix [<dos_file> [<unix_file>]]"
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
14 exit 1
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
15 fi
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
16
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
17 # First strip out all carriage-return and ctrl-Z's
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
18 if [ $# -gt 0 ]
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
19 then
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
20 tr -d '\015\032' < "$1" > $TMPFILE
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
21 else
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
22 tr -d '\015\032' > $TMPFILE
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
23 fi
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
24
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
25
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
26 if [ $# -eq 2 ]
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
27 then
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
28 mv -f $TMPFILE "$2"
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
29 else
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
30 cat $TMPFILE
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
31 rm $TMPFILE
0faa03a92843 Uploaded
dzesikah
parents:
diff changeset
32 fi