summarylogtreecommitdiffstats
path: root/fix-python-scripts.sh
blob: f0fb79f8309dc804f394f750e59eec5fde00097c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash

if [ -z "$1" ]; then
    echo "Usage: $0 <directory>"
    echo ""
    echo "Makes sure that all python scripts use the python2 command"
    exit 1
fi

for file in $(grep -rl -e 'env python *$' -e 'bin/python *$' $1); do
    if [ -z "$file" ]; then
        echo "Error finding files."
        exit 1
    fi
    sed -i 's,env python *$,env python2,g' $file
    sed -i 's,/usr/bin/python *$,/usr/bin/env python2,g' $file
done