git.net

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

uses both shell and python codes in one script.


On Thu, 03 Oct 2019 23:12:45 +1000, Chris Angelico wrote:


> Seems fine. Most of the code is elsewhere, and presumably has been
> written to support both Py2 and Py3; the file you're linking to is
> *just* a wrapper that finds an interpreter to use.
> 
> Though this should be unnecessary. A simple shebang of "/usr/bin/env
> python3" will suffice for many many situations (and then if someone
> specifically wants to run it in a legacy interpreter, an explicit
> "python2 scriptname.py" or "python scriptname.py" will work).

I'm very confusing on the following part in this script:

----
''':' # begin python string; this line is interpreted by the shell as `:`
which python  >/dev/null 2>&1 && exec python  "$0" "$@"
which python3 >/dev/null 2>&1 && exec python3 "$0" "$@"
which python2 >/dev/null 2>&1 && exec python2 "$0" "$@"
>&2 echo "error: cannot find python"
exit 1
'''
----

Any hints for the meaning of several ' used above?