* wrapPythonPrograms: rewrite the common "#! .../env python" idiom to

"#! .../python".

svn path=/nixpkgs/branches/modular-python/; revision=26583
This commit is contained in:
Eelco Dolstra
2011-03-28 17:19:27 +00:00
parent 7b3bda471d
commit 968496e69b
3 changed files with 14 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ wrapPythonPrograms() {
wrapPythonProgramsIn() {
local dir="$1"
local pythonPath="$2"
local python="$(type -p python)"
local i
declare -A pythonPathsSeen=()
@@ -15,6 +16,12 @@ wrapPythonProgramsIn() {
done
for i in $(find "$dir" -type f -perm +0100); do
# Rewrite "#! .../env python" to "#! /nix/store/.../python".
if head -n1 "$i" | grep -q '#!.*/env.*python'; then
sed -i "$i" -e "1 s^.*/env[ ]*python^#! $python^"
fi
if head -n1 "$i" | grep -q /python; then
echo "wrapping \`$i'..."
wrapProgram "$i" \