Add bash shell function to make python work like it should.
This uses the virtual /proc filesystem to identify when the user runs `python` without redirecting stdout/stdin. If this is the case, we run `python -i` instead. Otherwise, or if there are arguments, we run it verbatim. R=dnj@chromium.org BUG=598956 Review URL: https://codereview.chromium.org/1851113003 . git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299681 0039d316-1c4b-4281-b951-d872f2087c98changes/60/343160/1
parent
3466b0d6a6
commit
a218d7e915
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
# This alias allows invocations of `python` to work as expected under msys bash.
|
||||
# In particular, it detects if stdout+stdin are both attached to a pseudo-tty,
|
||||
# and if so, invokes python in interactive mode. If this is not the case, or
|
||||
# the user passes any arguments, python will be invoked unmodified.
|
||||
python() {
|
||||
if [[ $# > 0 ]]; then
|
||||
python.exe "$@"
|
||||
else
|
||||
readlink /proc/$$/fd/0 | grep pty > /dev/null
|
||||
TTY0=$?
|
||||
readlink /proc/$$/fd/1 | grep pty > /dev/null
|
||||
TTY1=$?
|
||||
if [ $TTY0 == 0 ] && [ $TTY1 == 0 ]; then
|
||||
python.exe -i
|
||||
else
|
||||
python.exe
|
||||
fi
|
||||
fi
|
||||
}
|
||||
Loading…
Reference in New Issue