: # Language default language=ENGLISH yesansw=y Echo="echo -e" # dos2unix shell script # help: dos2unix -e english # Hilfe: dos2unix [-d] deutsch # language=ENGLISH | GERMAN # yesansw=y | j autoswitch=n if test -n "$LANG" then language=$LANG yesansw=y fi if test "$1" = "-a" then autoswitch=y if test "$1" = "-a" ; then shift ; fi fi if test "$1" = "-e" -o "$language" = "ENGLISH" -o "$language" = "english" then language=english yesansw=y if test "$1" = "-e" ; then shift ; fi fi if test "$1" = "-d" -o "$language" = "GERMAN" -o "$language" = "german" then language=GERMAN yesansw=j if test "$1" = "-d" ; then shift ; fi fi if test "$1" = "-a" then autoswitch=y if test "$1" = "-a" ; then shift ; fi fi if test -z "$*" then $Echo "" $Echo "dos2unix shell script:" $Echo "----------------------" if test $language = GERMAN then $Echo "Konvertiere CR/LF auf LF, ^Z (= DOS eof) am Zeilenanfang entfernen." $Echo "Falls Datei nicht vorhanden ist, wird versucht, diese als " $Echo "zu oeffnen. ? und * in sind zulaessig." $Echo "" $Echo "Hinweis: falls in der Datei Sonderzeichen oder Umlaute verwendet werden," $Echo " erkennt sie UNIX u.U. nicht als eine ASCII Datei. Sie muessen dann die" $Echo " Konvertierung explizit bestaetigen oder den -a Switch (fuer alle) verwenden." $Echo "Siehe auch: unix2dos, FSadopt" else $Echo "converts CR/LF to LF, deletes ^Z (= DOS eof) on the end-of-file." $Echo "If the file does not exist, we will try to open it as ." $Echo "Wildcards ? and * in are allowed." $Echo "" $Echo "Note: when special characters or umlauts are used in the file, UNIX" $Echo " does not recognize it as an ASCII file. You must then explicitly confirm" $Echo " the conversion of this file, or use the -a switch (for all given files)." $Echo "See also: unix2dos, FSadopt" fi $Echo "" $Echo "Syntax: dos2unix [-a] file [file [file ...]]" $Echo " dos2unix [-a] file.prg [file2.prg [file3.prg ...]]" $Echo "" if test $language = GERMAN then $Echo "english: dos2unix -e [-a] ...." else $Echo "deutsch: dos2unix -d [-a] ...." fi $Echo "" $Echo "multisoft GmbH, 08/1992" exit 0 fi for ipar do if test -f "$ipar" then actualfile=$ipar else if test -f "$ipar.prg" then actualfile=$ipar.prg else if test $language = GERMAN then $Echo "***** Datei $ipar ist nicht vorhanden !" else $Echo "***** file $ipar does not exist !" fi break fi fi file $actualfile | grep ' text' >/dev/null if [ $? = 1 ] && test "$autoswitch" = "n" then if test $language = GERMAN then $Echo "***** $actualfile ist keine ASCII Datei. Konvertieren (j/n) ? \c" else $Echo "***** $actualfile is not ASCII file. Convert it (y/n) ? \c" fi read answer if test "$answer" != "$yesansw" then continue fi fi tempname=$actualfile.sav cp $actualfile $tempname 2>/dev/null _rc=$? if [ $_rc -ne 0 ] ; then tempname=`dirname $actualfile`/dos2unix.sav cp $actualfile $tempname 2>/dev/null _rc=$? fi if [ $_rc -eq 0 ] ; then tr -d "\015\032" < $tempname > $actualfile _rc=$? if [ $_rc -eq 0 -a "`tail -1 $actualfile`" != "" ] ; then $Echo >> $actualfile _rc=$? fi fi if [ $_rc -ne 0 ] ; then if test $language = GERMAN then $Echo "----> $actualfile NICHT konvertiert, Zugriff verweigert." else $Echo "----> $actualfile NOT converted, access denied." fi exit 1 fi if test $language = GERMAN then $Echo "----> $actualfile konvertiert." else $Echo "----> $actualfile converted." fi rm $tempname done