dosfndecode.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/sh
  2. # dosfndecode - dos filename decoder
  3. # (c) 2000 by plasmoid / thc <plasmoid@pimmel.com>
  4. #
  5. # convert files cutted to the dos extension (8.3 format) into proper unix
  6. # files by evaluating the ident definition. the ident definition can be
  7. # found in correct formated source trees, as for e.g. *surprise* *surprise*
  8. # the solaris source.
  9. #
  10. # this tool comes really handy if you have the broken solaris 2.7 source
  11. # that is flying around. but don't ask us, we don't have warez. sorry!
  12. #
  13. prepath=`pwd`
  14. if [ "x$1" = "x" -o ! -d $1 ] ; then
  15. echo "dos filename decoder - (C) 2000 by plasmoid / thc <plasmoid@pimmel.com>"
  16. echo "usage: $0 dir"
  17. echo " where dir is the directory to convert recursively"
  18. exit 0
  19. fi
  20. for j in `find $1 -type d` ; do
  21. echo " entering $j"
  22. cd $j
  23. for i in * ; do
  24. identline=`egrep -se \("#ident"\|"#pragma ident"\) $i`
  25. if [ "x$identline" != "x" -a "x`echo $0 | grep $i`" = "x" ] ; then
  26. newname=`echo $identline | sed s/@\(\#\)/!/g | cut -d! -f2`
  27. newname=`echo $newname | awk '{ print $1 }'`
  28. if [ "x`echo $newname | grep :`" != "x" ] ; then
  29. newname=`echo $newname | cut -d: -f2`
  30. fi
  31. if [ $i != $newname ] ; then
  32. echo " -- converting $i -> $newname"
  33. mv -f $i $newname
  34. fi
  35. fi
  36. done
  37. echo " leaving $j"
  38. cd $prepath
  39. done
  40. exit 1