Skip to content

Commit 0079f9c

Browse files
authored
Merge pull request #274 from michaelb/dev
Dev
2 parents b2b6f13 + 001be91 commit 0079f9c

28 files changed

+82
-52
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v1.3.11
2+
- Support compiler flags for C++ (courtesy of @jonathanffon) and all other languages
3+
- Scripts use \cat instead of /bin/cat (courtesy of @GaetanLepage)
4+
15
## v1.3.10
26
- Fix missing documentation in the online wiki
37
- Fix interpreters broken when they were not explicitely the default for their filetype

Cargo.lock

+25-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sniprun"
3-
version = "1.3.10"
3+
version = "1.3.11"
44
authors = ["michaelb <[email protected]>"]
55
rust-version = "1.65"
66
edition = "2018"

doc/sources/common_options.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,16 @@ interpreter_options = {
107107
interpreter = "python3.9"
108108
}
109109
Rust_original = {
110-
compiler = "/home/user/bin/rustc-patched"
110+
compiler = "/home/user/bin/rustc-patched -Zlocation-detail=none"
111111
}
112112
},
113113
```
114114

115115
You can see what interpreters/compilers are being used at any time by watching sniprun's log for the line
116116
"using compiler XXXX" or "using interpreter XXXX" when you run a snippet.
117+
While options can (generally) be added to these interpreters/compilers strings, mind that some options are often already passed, and
118+
sometimes mandatory (ex: "-o main_file_name", "--nologo") and whatever is added can mess up the format
119+
sniprun internally expect, or be straight out incompatible with the formers. Be careful!
117120

118121
Exceptions:
119122
- Scala_original has both interpreter and compiler keys that should be set consistently with each other

doc/sources/interpreters/FSharp_fifo.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ There is a lot of thing in that script but to replicate, you just have to:
3535

3636
```bash
3737
#!/bin/bash
38-
/bin/cat pipe_in | dotnet fsi
38+
cat pipe_in | dotnet fsi
3939

4040
# or replace 'dotnet fsi' by whatever you cant to try
4141
```

src/interpreters/Ada_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ impl Interpreter for Ada_original {
105105
.expect("Unable to write to file for language_subname");
106106

107107
let compiler = Ada_original::get_compiler_or(&self.data, "gnatmake");
108-
let output = Command::new(compiler)
108+
let output = Command::new(compiler.split_whitespace().next().unwrap())
109+
.args(compiler.split_whitespace().skip(1))
109110
.arg("main")
110111
.arg(&self.main_file_path)
111112
.current_dir(&self.ada_work_dir)

src/interpreters/Bash_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ impl Interpreter for Bash_original {
105105

106106
fn execute(&mut self) -> Result<String, SniprunError> {
107107
let interpreter = Bash_original::get_interpreter_or(&self.data, "bash");
108-
let output = Command::new(interpreter)
108+
let output = Command::new(interpreter.split_whitespace().next().unwrap())
109+
.args(interpreter.split_whitespace().skip(1))
109110
.arg(&self.main_file_path)
110111
.args(&self.get_data().cli_args)
111112
.output()

src/interpreters/CS_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ impl Interpreter for CS_original {
9494

9595
fn execute(&mut self) -> Result<String, SniprunError> {
9696
let interpreter = CS_original::get_interpreter_or(&self.data, "coffee");
97-
let output = Command::new(interpreter)
97+
let output = Command::new(interpreter.split_whitespace().next().unwrap())
98+
.args(interpreter.split_whitespace().skip(1))
9899
.arg(&self.main_file_path)
99100
.args(&self.get_data().cli_args)
100101
.output()

src/interpreters/CSharp_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ impl Interpreter for CSharp_original {
128128
.expect("Unable to write to file for csharp-original");
129129

130130
//compile it (to the bin_path that arleady points to the rigth path)
131-
let output = Command::new(&self.compiler)
131+
let output = Command::new(self.compiler.split_whitespace().next().unwrap())
132+
.args(self.compiler.split_whitespace().skip(1))
132133
.arg(String::from("-out:") + &self.bin_path)
133134
.arg(&self.main_file_path)
134135
.output()

src/interpreters/C_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,9 @@ impl Interpreter for C_original {
179179
let mut _file =
180180
File::create(&self.main_file_path).expect("Failed to create file for c-original");
181181
write(&self.main_file_path, &self.code).expect("Unable to write to file for c-original");
182-
let mut cmd = Command::new(&self.compiler);
182+
let mut cmd = Command::new(self.compiler.split_whitespace().next().unwrap());
183183
let cmd = cmd
184+
.args(self.compiler.split_whitespace().skip(1))
184185
.arg(&self.main_file_path)
185186
.arg("-o")
186187
.arg(&self.bin_path)

src/interpreters/Clojure_fifo.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ impl Interpreter for Clojure_fifo {
213213
Ok(())
214214
}
215215
fn execute(&mut self) -> Result<String, SniprunError> {
216-
let output = Command::new(self.interpreter.clone())
216+
217+
let output = Command::new(self.interpreter.split_whitespace().next().unwrap())
218+
.args(self.interpreter.split_whitespace().skip(1))
217219
.arg(&self.main_file_path)
218220
.args(&self.get_data().cli_args)
219221
.output()

src/interpreters/D_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ impl Interpreter for D_original {
9191
fn execute(&mut self) -> Result<String, SniprunError> {
9292
//run th binary and get the std output (or stderr)
9393
let interpreter = D_original::get_interpreter_or(&self.data, "dmd");
94-
let output = Command::new(interpreter)
94+
let output = Command::new(interpreter.split_whitespace().next().unwrap())
95+
.args(interpreter.split_whitespace().skip(1))
9596
.arg("-run")
9697
.arg(&self.main_file_path)
9798
.output()

src/interpreters/Elixir_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ impl Interpreter for Elixir_original {
165165
}
166166
fn execute(&mut self) -> Result<String, SniprunError> {
167167
let interpreter = Elixir_original::get_interpreter_or(&self.data, "elixir");
168-
let output = Command::new(interpreter)
168+
let output = Command::new(interpreter.split_whitespace().next().unwrap())
169+
.args(interpreter.split_whitespace().skip(1))
169170
.arg(&self.main_file_path)
170171
.args(&self.get_data().cli_args)
171172
.output()

src/interpreters/Go_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ impl Interpreter for Go_original {
236236
write(&self.main_file_path, &self.code).expect("Unable to write to file for go-original");
237237

238238
//compile it (to the bin_path that arleady points to the rigth path)
239-
let output = Command::new(&self.compiler)
239+
let output = Command::new(self.compiler.split_whitespace().next().unwrap())
240+
.args(self.compiler.split_whitespace().skip(1))
240241
.arg("build")
241242
.arg("-o")
242243
.arg(&self.go_work_dir)

src/interpreters/Haskell_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ impl Interpreter for Haskell_original {
106106
&self.main_file_path, &self.bin_path
107107
);
108108
let compiler = Haskell_original::get_compiler_or(&self.data, "ghc");
109-
let output = Command::new(compiler)
109+
let output = Command::new(compiler.split_whitespace().next().unwrap())
110+
.args(compiler.split_whitespace().skip(1))
110111
.arg("-dynamic")
111112
.arg("-o")
112113
.arg(self.bin_path.clone())

src/interpreters/JS_TS_bun.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ impl Interpreter for JS_TS_bun {
195195
}
196196
}
197197
let interpreter = JS_TS_bun::get_interpreter_or(&self.data, "bun");
198-
let output = Command::new(interpreter)
198+
let output = Command::new(interpreter.split_whitespace().next().unwrap())
199+
.args(interpreter.split_whitespace().skip(1))
199200
.arg("run")
200201
.arg("--silent")
201202
.args(bun_opts.split_whitespace())

src/interpreters/JS_TS_deno.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ impl Interpreter for JS_TS_deno {
214214
fn execute(&mut self) -> Result<String, SniprunError> {
215215
//run the binary and get the std output (or stderr)
216216
let interpreter = JS_TS_deno::get_interpreter_or(&self.data, "deno");
217-
let output = Command::new(interpreter)
217+
let output = Command::new(interpreter.split_whitespace().next().unwrap())
218+
.args(interpreter.split_whitespace().skip(1))
218219
.arg("run")
219220
.arg("-A")
220221
.arg("--unstable")

src/interpreters/JS_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ impl Interpreter for JS_original {
9494

9595
fn execute(&mut self) -> Result<String, SniprunError> {
9696
let interpreter = JS_original::get_interpreter_or(&self.data, "node");
97-
let output = Command::new(interpreter)
97+
let output = Command::new(interpreter.split_whitespace().next().unwrap())
98+
.args(interpreter.split_whitespace().skip(1))
9899
.arg(&self.main_file_path)
99100
.args(&self.get_data().cli_args)
100101
.output()

src/interpreters/Java_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ impl Interpreter for Java_original {
102102

103103
let compiler = Java_original::get_compiler_or(&self.data, "javac");
104104
//compile it (to the bin_path that arleady points to the rigth path)
105-
let output = Command::new(compiler)
105+
let output = Command::new(compiler.split_whitespace().next().unwrap())
106+
.args(compiler.split_whitespace().skip(1))
106107
.arg("-d")
107108
.arg(&self.java_work_dir)
108109
.arg(&self.main_file_path)

src/interpreters/Julia_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ impl Interpreter for Julia_original {
180180
Ok(())
181181
}
182182
fn execute(&mut self) -> Result<String, SniprunError> {
183-
let output = Command::new(&self.interpreter)
183+
let output = Command::new(self.interpreter.split_whitespace().next().unwrap())
184+
.args(self.interpreter.split_whitespace().skip(1))
184185
.args(&self.interpreter_args)
185186
.arg(&self.main_file_path)
186187
.args(&self.get_data().cli_args)

src/interpreters/Lua_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ impl Interpreter for Lua_original {
108108

109109
fn execute(&mut self) -> Result<String, SniprunError> {
110110
let interpreter = Lua_original::get_interpreter_or(&self.data, "lua");
111-
let output = Command::new(interpreter)
111+
let output = Command::new(interpreter.split_whitespace().next().unwrap())
112+
.args(interpreter.split_whitespace().skip(1))
112113
.arg(&self.main_file_path)
113114
.args(&self.get_data().cli_args)
114115
.output()

src/interpreters/Mathematica_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ impl Interpreter for Mathematica_original {
238238
fn execute(&mut self) -> Result<String, SniprunError> {
239239
//run th binary and get the std output (or stderr)
240240
let interpreter = Mathematica_original::get_interpreter_or(&self.data, "WolframKernel");
241-
let output = Command::new(interpreter)
241+
let output = Command::new(interpreter.split_whitespace().next().unwrap())
242+
.args(interpreter.split_whitespace().skip(1))
242243
.arg("-noprompt")
243244
.arg("-script")
244245
.arg(&self.main_file_path)

src/interpreters/Python3_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ impl Interpreter for Python3_original {
243243
Ok(())
244244
}
245245
fn execute(&mut self) -> Result<String, SniprunError> {
246-
let output = Command::new(&self.interpreter)
246+
let output = Command::new(self.interpreter.split_whitespace().next().unwrap())
247+
.args(self.interpreter.split_whitespace().skip(1))
247248
.arg(&self.main_file_path)
248249
.args(&self.get_data().cli_args)
249250
.output()

src/interpreters/R_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ impl Interpreter for R_original {
9797

9898
fn execute(&mut self) -> Result<String, SniprunError> {
9999
let interpreter = R_original::get_interpreter_or(&self.data, "Rscript");
100-
let output = Command::new(interpreter)
100+
let output = Command::new(interpreter.split_whitespace().next().unwrap())
101+
.args(interpreter.split_whitespace().skip(1))
101102
.arg(&self.main_file_path)
102103
.args(&self.get_data().cli_args)
103104
.output()

src/interpreters/Ruby_original.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ impl Interpreter for Ruby_original {
9494

9595
fn execute(&mut self) -> Result<String, SniprunError> {
9696
let interpreter = Ruby_original::get_interpreter_or(&self.data, "ruby");
97-
let output = Command::new(interpreter)
97+
let output = Command::new(interpreter.split_whitespace().next().unwrap())
98+
.args(interpreter.split_whitespace().skip(1))
9899
.arg(&self.main_file_path)
99100
.args(&self.get_data().cli_args)
100101
.output()

0 commit comments

Comments
 (0)