#!/bin/sh
#
# Usage: fix-script-magic.sh <filename> <interpreter path>

fixmagic () {
    ed -s "$1" <<EOF
1d
1i
#!$2
.
w
q
EOF
}

for file in `find $1 -type f`; do
    if head -1 $file | grep -q '^#!.*python'; then
        echo 'Fixing magic for' $file
        fixmagic $file $2
    fi
done
