[Lunar-commits] CVS: moonbase/editors/recode dos2unix, 1.1,
1.2 unix2dos, 1.1, 1.2
Auke Kok
sofar at lunar-linux.org
Fri Mar 18 08:27:21 UTC 2005
Update of /var/cvs/lunar/moonbase/editors/recode
In directory espresso.foo-projects.org:/home/sofar/active/moonbase/editors/recode
Modified Files:
dos2unix unix2dos
Log Message:
More flexible and simple: no tmpfiles needed and passthru STDIO usage.
Index: dos2unix
===================================================================
RCS file: /var/cvs/lunar/moonbase/editors/recode/dos2unix,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dos2unix 15 Mar 2005 13:38:51 -0000 1.1
+++ dos2unix 18 Mar 2005 08:27:19 -0000 1.2
@@ -1,12 +1,13 @@
#!/bin/bash
-if [ -z "$1" -o -z "$2" ]; then
- echo "$0 requires two arguments: infile outfile"
- exit 1
+if [ -z "$1" -a -z "$2" ]; then
+ # use STDIN and STDOUT
+ cat - | recode --force IBMPC..Latin1
+elif [ -n "$1" -a -n "$2" ]; then
+ # INFILE and OUTFILE
+ recode --force IBMPC..Latin1 < "$1" > "$2"
else
- TMPFILE=$(mktemp)
- cp "$1" $TMPFILE
- recode --force IBMPC..Latin1 $TMPFILE
- mv $TMPFILE "$2"
+ echo "$0 requires zero or two arguments: [infile] [outfile]"
+ exit 1
fi
Index: unix2dos
===================================================================
RCS file: /var/cvs/lunar/moonbase/editors/recode/unix2dos,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- unix2dos 15 Mar 2005 13:38:51 -0000 1.1
+++ unix2dos 18 Mar 2005 08:27:19 -0000 1.2
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+if [ -z "$1" -a -z "$2" ]; then
+ # use STDIN and STDOUT
+ cat - | recode --force Latin1..IBMPC
+elif [ -n "$1" -a -n "$2" ]; then
+ # INFILE and OUTFILE
+ recode --force Latin1..IBMPC < "$1" > "$2"
+else
+ echo "$0 requires zero or two arguments: [infile] [outfile]"
+ exit 1
+fi
+
More information about the Lunar-commits
mailing list