diff options
author | aszlig <aszlig@redmoonstudios.org> | 2014-07-28 04:18:21 +0200 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2014-07-28 04:18:21 +0200 |
commit | 5f01cc70d3a65a4d904a2040343ca5bfdfbaaff3 (patch) | |
tree | 62f4195026917bb607c5a4eda196be822dc38dc8 /pkgs | |
parent | e57249ab20f01041628842ea1d84eae15fa75dc8 (diff) | |
download | nixlib-5f01cc70d3a65a4d904a2040343ca5bfdfbaaff3.tar nixlib-5f01cc70d3a65a4d904a2040343ca5bfdfbaaff3.tar.gz nixlib-5f01cc70d3a65a4d904a2040343ca5bfdfbaaff3.tar.bz2 nixlib-5f01cc70d3a65a4d904a2040343ca5bfdfbaaff3.tar.lz nixlib-5f01cc70d3a65a4d904a2040343ca5bfdfbaaff3.tar.xz nixlib-5f01cc70d3a65a4d904a2040343ca5bfdfbaaff3.tar.zst nixlib-5f01cc70d3a65a4d904a2040343ca5bfdfbaaff3.zip |
python-wrapper: Fix fixup for wrapped argv[0].
Fixes issues introduced by 24ef871e6a1c858af3f9984a5b526c83b24520ed. The problem here is that "import sys; sys.argv[0] = ..." is just appended after the first "#!", which in turn breaks things such as encoding specifications. A second problem - although not very common - is when there's another #! within the script. This should take care of both cases. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/development/python-modules/generic/wrap.sh | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/pkgs/development/python-modules/generic/wrap.sh b/pkgs/development/python-modules/generic/wrap.sh index dda9f4877f67..f81adf0bae93 100644 --- a/pkgs/development/python-modules/generic/wrap.sh +++ b/pkgs/development/python-modules/generic/wrap.sh @@ -26,7 +26,9 @@ wrapPythonProgramsIn() { # dont wrap EGG-INFO scripts since they are called from python if echo "$i" | grep -v EGG-INFO/scripts; then echo "wrapping \`$i'..." - sed -i "$i" -e "/^#\!/a import sys; sys.argv[0] = '$(basename $i)'" + sed -i "$i" -e '1,/#!/ { /^#\!/,/^[^#]/ { + /^[^#]/i import sys; sys.argv[0] = '"'$(basename "$i")'"' + }}' wrapProgram "$i" \ --prefix PYTHONPATH ":" $program_PYTHONPATH \ --prefix PATH ":" $program_PATH |