PageRenderTime 36ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/ncftp-3.2.5/sh/dos2unix.sh

#
Shell | 33 lines | 30 code | 2 blank | 1 comment | 6 complexity | 8638bfd1311433e3dcbd8a999a696793 MD5 | raw file
Possible License(s): AGPL-3.0
  1. #!/bin/sh
  2. es=1
  3. if [ $# -eq 0 ] ; then
  4. exec tr -d '\015\032'
  5. elif [ ! -f "$1" ] ; then
  6. echo "Not found: $1" 1>&2
  7. else
  8. for f in "$@" ; do
  9. if tr -d '\015\032' < "$f" > "$f.tmp" ; then
  10. if cmp "$f" "$f.tmp" > /dev/null ; then
  11. rm -f "$f.tmp"
  12. else
  13. touch -r "$f" "$f.tmp"
  14. if mv "$f" "$f.bak" ; then
  15. if mv "$f.tmp" "$f" ; then
  16. rm -f "$f.bak"
  17. es=$?
  18. echo " converted $f"
  19. else
  20. rm -f "$f.tmp"
  21. fi
  22. else
  23. rm -f "$f.tmp"
  24. fi
  25. fi
  26. else
  27. rm -f "$f.tmp"
  28. fi
  29. done
  30. fi
  31. exit $es