#---------------------------------------------------------------------------- # /usr/bin/dtou - convert linebreak dos to unix # # Creation: long time ago # Last update: $Id$ # # Copyright (c) 2001-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- #! /bin/sh for j in "$@" do # convert file only if command file says: # ... with CRLF line terminators ftype='' ftype=$(LANG=C file "${j}" 2>/dev/null) echo ${ftype} | grep -Eq 'with CRLF line terminators|with CRLF, LF line terminators' is_dos=${?} if [ "${is_dos}" -eq "0" ] then sed 's/ *$//g' < "${j}" > /tmp/$$ # strip CRs at end of lines cp /tmp/$$ "${j}" # cp to keep perms, e.g. x-bit rm /tmp/$$ fi done # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------