blob: 39852024f2a8c2affc4438e8b5ab379a2e75c33a [file] [log] [blame]
iannucci@chromium.orga218d7e2016-04-04 21:22:42 +00001#!/bin/bash
2# This alias allows invocations of `python` to work as expected under msys bash.
3# In particular, it detects if stdout+stdin are both attached to a pseudo-tty,
4# and if so, invokes python in interactive mode. If this is not the case, or
5# the user passes any arguments, python will be invoked unmodified.
6python() {
7 if [[ $# > 0 ]]; then
8 python.exe "$@"
9 else
10 readlink /proc/$$/fd/0 | grep pty > /dev/null
11 TTY0=$?
12 readlink /proc/$$/fd/1 | grep pty > /dev/null
13 TTY1=$?
14 if [ $TTY0 == 0 ] && [ $TTY1 == 0 ]; then
15 python.exe -i
16 else
17 python.exe
18 fi
19 fi
20}