@@ -24,6 +24,8 @@ pub fn run(package: &Package, binary: Option<String>, params: &Vec<String>) -> b
24
24
let mut args = vec ! [ "run" . to_string( ) , "--rm" . to_string( ) ] ;
25
25
if interactive {
26
26
args. push ( "-i" . to_string ( ) ) ;
27
+ } else {
28
+ args. push ( "-it" . to_string ( ) ) ;
27
29
}
28
30
29
31
add_volumes ( package, & mut args) ;
@@ -85,39 +87,53 @@ fn add_binary_entrypoint(package: &Package, binary: &Option<String>, args: &mut
85
87
}
86
88
}
87
89
88
- fn get_stdio ( config : & crate :: configs:: user:: Root ) -> ( Stdio , Stdio ) {
90
+ fn get_stdio ( config : & crate :: configs:: user:: Root , stdin_buffer : & Option < Vec < u8 > > ) -> ( Stdio , Stdio , Stdio ) {
91
+ let stdin = if let Some ( b) = stdin_buffer {
92
+ if b. is_empty ( ) {
93
+ Stdio :: inherit ( )
94
+ } else {
95
+ Stdio :: piped ( )
96
+ }
97
+ } else {
98
+ Stdio :: inherit ( )
99
+ } ;
100
+
89
101
let stdout = if config. experimental . capture_stdout {
90
102
Stdio :: piped ( )
91
103
} else {
92
104
Stdio :: inherit ( )
93
105
} ;
106
+
94
107
let stderr = if config. experimental . capture_stderr {
95
108
Stdio :: piped ( )
96
109
} else {
97
110
Stdio :: inherit ( )
98
111
} ;
99
- ( stdout, stderr)
112
+
113
+ ( stdin, stdout, stderr)
100
114
}
101
115
102
116
fn run_command_with_args ( command : & str , args : & [ String ] , stdin_buffer : Option < Vec < u8 > > ) -> bool {
103
- debug ! ( "Running command: {} {:? }" , command, args) ;
117
+ debug ! ( "Running command: {} {}" , command, args. join ( " " ) ) ;
104
118
105
119
let config = UserConfig :: load ( ) . unwrap_or_default ( ) ;
106
- let ( stdout, stderr) = get_stdio ( & config) ;
120
+ let ( stdin , stdout, stderr) = get_stdio ( & config, & stdin_buffer ) ;
107
121
108
122
let mut child = Command :: new ( command)
109
123
. args ( args)
110
124
. stdout ( stdout)
111
125
. stderr ( stderr)
112
- . stdin ( Stdio :: piped ( ) )
126
+ . stdin ( stdin )
113
127
. spawn ( )
114
128
. expect ( "Failed to spawn command" ) ;
115
129
116
130
if let Some ( buffer) = stdin_buffer {
117
- let child_stdin = child. stdin . as_mut ( ) . expect ( "Failed to open stdin" ) ;
118
- child_stdin
119
- . write_all ( & buffer)
120
- . expect ( "Failed to write to stdin" ) ;
131
+ if buffer. len ( ) > 0 {
132
+ let child_stdin = child. stdin . as_mut ( ) . expect ( "Failed to open stdin" ) ;
133
+ child_stdin
134
+ . write_all ( & buffer)
135
+ . expect ( "Failed to write to stdin" ) ;
136
+ }
121
137
}
122
138
123
139
let stdout_thread = spawn_log_thread (
0 commit comments