Hi! Hartmut Goebel <h.goe...@crazy-compilers.com> skribis:
> answering on a mail which Ricardo CCed to me and which did not make it > to the list yet. Thus I full-quote. > > Am 04.11.2017 um 23:30 schrieb Ricardo Wurmus: >> How about this: >> >> --8<---------------cut here---------------start------------->8--- >> #!/home/rekado/.guix-profile/bin/guile --no-auto-compile >> #!# (let (($0 (car (command-line)))) (execl >> "/home/rekado/.guix-profile/bin/python3" $0 $0)) >> #!/home/rekado/.guix-profile/bin/python3 >> import sys; print("hello from python: "+sys.argv[0]) >> --8<---------------cut here---------------end--------------->8--- >> >> The first two lines are Guile code, but they are also line comments in >> shell, Perl, Python, Ruby, and R. The Guile code in this example calls >> the script again as a Python script. Before doing that it can set >> environment variables, like so: >> >> --8<---------------cut here---------------start------------->8--- >> #!/home/rekado/.guix-profile/bin/guile --no-auto-compile >> #!# >> #\- (setenv "PYTHONPATH" (string-append "/gnu/store/foo:/gnu/store/bar:" >> (getenv "PYTHONPATH"))) >> #\- (let (($0 (car (command-line)))) (execl >> "/home/rekado/.guix-profile/bin/python3" $0 $0)) >> #!/home/rekado/.guix-profile/bin/python3 >> import sys; print("hello from python: "+sys.argv[0]) >> print(sys.path) >> --8<---------------cut here---------------end--------------->8--- >> >> Did I overlook something? Or could we use this hack to remove separate >> wrapper scripts for Perl, Python, Ruby, and R? Overall this looks good to me (with the adjustments Hartmut mentions). Now, we should have a white list of languages for which this can be done. ‘wrap-program’ would grab the shebang and check if the basename of the interpreter is in that white list. Thoughts? Ludo’.