added unreleased README
[oweals/thc-archive.git] / Tools / dosfndecode.sh
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
14 prepath=`pwd`
15
16 if [ "x$1" = "x" -o ! -d $1 ] ; then
17    echo "dos filename decoder - (C) 2000 by plasmoid / thc <plasmoid@pimmel.com>"
18    echo "usage: $0 dir"
19    echo "       where dir is the directory to convert recursively"
20    exit 0
21 fi
22
23 for j in `find $1 -type d` ; do 
24 echo " entering $j"
25 cd $j
26    for i in * ; do 
27       identline=`egrep -se \("#ident"\|"#pragma ident"\) $i`
28
29       if [ "x$identline" != "x" -a "x`echo $0 | grep $i`" = "x" ] ; then
30          newname=`echo $identline | sed s/@\(\#\)/!/g | cut -d! -f2`
31          newname=`echo $newname | awk '{ print $1 }'`
32          if [ "x`echo $newname | grep :`" != "x" ] ; then
33             newname=`echo $newname | cut -d: -f2`
34          fi
35          if [ $i != $newname ] ; then
36             echo " -- converting $i -> $newname"
37             mv -f $i $newname
38          fi
39       fi
40    done
41 echo " leaving $j"
42 cd $prepath
43 done
44 exit 1