guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: avoid wrapper scripts when possible


From: Hartmut Goebel
Subject: Re: avoid wrapper scripts when possible
Date: Sun, 5 Nov 2017 12:10:42 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

Hi,

Ricado proposed a new and better solution already. Nevertheless I want to comment on this proposal, sint it includes a pitfall and would not work:

Am 03.11.2017 um 22:17 schrieb Ricardo Wurmus:
exec /home/rekado/.guix-profile/bin/python <(/run/current-system/profile/bin/tail -n +4 "$0")
[...]
This seems to work just fine and off the top of my head I can’t think of
a situation where this would fail — unless the wrapped script performed
the same kind of trick of reading its contents through $0.  (How likely
is that?)

Indeed for Python programs it is quite common to revert to the filename using the variable "__file__". And if feeding in the script from stdin would set __file__ to "<stdin>". Using __file__ is more often used in package modules than in scripts (which could use $0 (sys.argv[0]). Anyway this is a pitfall we should avoid.

Please not that Ricardo's new solution, based on guile and execl does not suffer from this problem (I verified).
-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | address@hidden               |
| www.crazy-compilers.com | compilers which you thought are impossible |

reply via email to

[Prev in Thread] Current Thread [Next in Thread]