annotate tools/rdock/bin/to_unix @ 1:30e2440b2173 draft

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