File: unix2mac

package info (click to toggle)
uqwk 2.21-15
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 532 kB
  • ctags: 473
  • sloc: ansic: 4,555; sh: 1,075; makefile: 126
file content (44 lines) | stat: -rw-r--r-- 809 bytes parent folder | download | duplicates (4)
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
#!/bin/sh
# $Id: unix2mac,v 1.1 1999/03/08 15:28:41 js Exp $

prog=`basename $0`
tmp=/tmp/$prog.$$

trap 'rm -f $tmp' 0 1

case $# in
	0)	;;
	1)	if cp $1 $tmp 2> /dev/null; then :; else echo "$prog: could not open $1"; exit 1; fi
		exec < $tmp > $1
		;;
	2)	if cp $1 $tmp 2> /dev/null; then :; else echo "$prog: could not open $1"; exit 1; fi
		exec < $tmp > $2
		;;
	*)	echo "Usage: $prog [infile] [outfile]"
		exit 1
		;;
esac

case $prog in
	mac2unix)	tr '\015' '\012'
			;;
	unix2mac)	tr '\012' '\015'
			;;
	dos2unix)	sed -e 's/
$//g'
			;;
	unix2dos)	sed -e 's/$/
/g'
			;;
	dos2mac)	sed -e 's/
$//g' | tr '\012' '\015'
			;;
	mac2dos)	tr '\015' '\012' | sed -e 's/$/
/g'
			;;
	dos2dos|mac2mac|unix2unix)
			;;
	*)		echo 'I can only convert between Mac, Unix and DOS.  What else?'
			exit 1
			;;
esac