From 5a0202ec84c60d15e440a8bb90f274af6f531871 Mon Sep 17 00:00:00 2001
From: Alex Tokarev <aleksator@gmail.com>
Date: Sat, 1 Jun 2019 17:19:48 +0300
Subject: [PATCH] Add interactive option to improve compatibility with other
 shells

Fixes shell invocation for programs, requesting interactive session
with '-i' command.

See https://youtrack.jetbrains.com/issue/IDEA-215394
---
 src/main.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/main.rs b/src/main.rs
index 8fb6c765..6e4cd7d3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -26,6 +26,7 @@ fn main() {
     let mut args = env::args().skip(1);
     let mut script_path = None;
     let mut key_bindings = None;
+    let mut force_interactive = false;
     while let Some(arg) = args.next() {
         match arg.as_str() {
             "-o" => match args.next().as_ref().map(|s| s.as_str()) {
@@ -51,6 +52,7 @@ fn main() {
                 println!("{}", MAN_ION);
                 return;
             }
+            "-i" | "--interactive" => force_interactive = true,
             _ => {
                 script_path = Some(arg);
                 break;
@@ -75,7 +77,7 @@ fn main() {
         shell.execute_script(command.as_bytes());
     } else if let Some(path) = script_path {
         shell.execute_file(&path.as_str());
-    } else if stdin_is_a_tty {
+    } else if stdin_is_a_tty || force_interactive {
         let mut interactive = InteractiveBinary::new(shell);
         if let Some(key_bindings) = key_bindings {
             interactive.set_keybindings(key_bindings);
-- 
GitLab