Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Unified Diff: bootstrap/win/profile.d.python.sh

Issue 1851113003: Add bash shell function to make python work like it should. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: add comment Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | bootstrap/win/win_tools.bat » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bootstrap/win/profile.d.python.sh
diff --git a/bootstrap/win/profile.d.python.sh b/bootstrap/win/profile.d.python.sh
new file mode 100755
index 0000000000000000000000000000000000000000..39852024f2a8c2affc4438e8b5ab379a2e75c33a
--- /dev/null
+++ b/bootstrap/win/profile.d.python.sh
@@ -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
+}
« no previous file with comments | « no previous file | bootstrap/win/win_tools.bat » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698