Saturday, April 30, 2005

Already using the bash power :)

In the DBUS python code,i came across few examples which had a missing interpreter at the top .
So i sent a mail to mailing list and J5 let me contribute by asking me to submit the patch.
I really like the spirit of Free Software ,i started creating the patches after creating a couple of them.I said
"Wait"...Whats the point of bash if you keep repeating the samething. :)
So here is the script that creates the patch for the missing interpreter.

#!/bin/bash

for sourcefile in $(ls *.py )
do
if head -n 1 $sourcefile |grep -e '^#!' &> /dev/null
then
echo "$sourcefile has some interpretor"
else
cp $sourcefile ${sourcefile}_orig
cat ${sourcefile}_orig | sed -e '1i#!/usr/bin/env python\' -e '' > $sourcefile
diff -u ${sourcefile}_orig $sourcefile >> examples.patch
fi
done

Yo

0 Comments:

Post a Comment

<< Home