diff --git a/CHANGELOG.md b/CHANGELOG.md index 84ceaf9..28a2de2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.3.11 +- Support compiler flags for C++ (courtesy of @jonathanffon) and all other languages +- Scripts use \cat instead of /bin/cat (courtesy of @GaetanLepage) + ## v1.3.10 - Fix missing documentation in the online wiki - Fix interpreters broken when they were not explicitely the default for their filetype diff --git a/Cargo.lock b/Cargo.lock index 9e81e74..b024ae7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,9 +49,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.5" +version = "0.21.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "c79fed4cdb43e993fcdadc7e58a09fd0e3e649c4436fa11da71c9f1f3ee7feb9" [[package]] name = "bitflags" @@ -271,9 +271,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if 1.0.0", "libc", @@ -341,9 +341,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libredox" @@ -384,9 +384,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "miniz_oxide" @@ -494,18 +494,18 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro2" -version = "1.0.71" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -707,9 +707,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] @@ -725,9 +725,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", @@ -736,9 +736,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -798,7 +798,7 @@ checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "sniprun" -version = "1.3.10" +version = "1.3.11" dependencies = [ "close_fds", "dirs", @@ -833,9 +833,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.43" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -844,18 +844,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.52" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a48fd946b02c0a526b2e9481c8e2a17755e47039164a86c4070446e3a4614d" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.52" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7fbe9b594d6568a6a1443250a7e67d80b74e1e96f6d1715e1e21cc1888291d3" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 77ded9e..59c46c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sniprun" -version = "1.3.10" +version = "1.3.11" authors = ["michaelb "] rust-version = "1.65" edition = "2018" diff --git a/doc/sources/common_options.md b/doc/sources/common_options.md index 1bc5952..71fcd99 100644 --- a/doc/sources/common_options.md +++ b/doc/sources/common_options.md @@ -107,13 +107,16 @@ interpreter_options = { interpreter = "python3.9" } Rust_original = { - compiler = "/home/user/bin/rustc-patched" + compiler = "/home/user/bin/rustc-patched -Zlocation-detail=none" } }, ``` You can see what interpreters/compilers are being used at any time by watching sniprun's log for the line "using compiler XXXX" or "using interpreter XXXX" when you run a snippet. +While options can (generally) be added to these interpreters/compilers strings, mind that some options are often already passed, and +sometimes mandatory (ex: "-o main_file_name", "--nologo") and whatever is added can mess up the format +sniprun internally expect, or be straight out incompatible with the formers. Be careful! Exceptions: - Scala_original has both interpreter and compiler keys that should be set consistently with each other diff --git a/doc/sources/interpreters/FSharp_fifo.md b/doc/sources/interpreters/FSharp_fifo.md index 124c202..71f5ed4 100644 --- a/doc/sources/interpreters/FSharp_fifo.md +++ b/doc/sources/interpreters/FSharp_fifo.md @@ -35,7 +35,7 @@ There is a lot of thing in that script but to replicate, you just have to: ```bash #!/bin/bash -/bin/cat pipe_in | dotnet fsi +cat pipe_in | dotnet fsi # or replace 'dotnet fsi' by whatever you cant to try ``` diff --git a/src/interpreters/Ada_original.rs b/src/interpreters/Ada_original.rs index 61444c5..9bd06d2 100644 --- a/src/interpreters/Ada_original.rs +++ b/src/interpreters/Ada_original.rs @@ -105,7 +105,8 @@ impl Interpreter for Ada_original { .expect("Unable to write to file for language_subname"); let compiler = Ada_original::get_compiler_or(&self.data, "gnatmake"); - let output = Command::new(compiler) + let output = Command::new(compiler.split_whitespace().next().unwrap()) + .args(compiler.split_whitespace().skip(1)) .arg("main") .arg(&self.main_file_path) .current_dir(&self.ada_work_dir) diff --git a/src/interpreters/Bash_original.rs b/src/interpreters/Bash_original.rs index 420ec36..55d77c6 100644 --- a/src/interpreters/Bash_original.rs +++ b/src/interpreters/Bash_original.rs @@ -105,7 +105,8 @@ impl Interpreter for Bash_original { fn execute(&mut self) -> Result { let interpreter = Bash_original::get_interpreter_or(&self.data, "bash"); - let output = Command::new(interpreter) + let output = Command::new(interpreter.split_whitespace().next().unwrap()) + .args(interpreter.split_whitespace().skip(1)) .arg(&self.main_file_path) .args(&self.get_data().cli_args) .output() diff --git a/src/interpreters/CS_original.rs b/src/interpreters/CS_original.rs index c1427d5..ce333b2 100644 --- a/src/interpreters/CS_original.rs +++ b/src/interpreters/CS_original.rs @@ -94,7 +94,8 @@ impl Interpreter for CS_original { fn execute(&mut self) -> Result { let interpreter = CS_original::get_interpreter_or(&self.data, "coffee"); - let output = Command::new(interpreter) + let output = Command::new(interpreter.split_whitespace().next().unwrap()) + .args(interpreter.split_whitespace().skip(1)) .arg(&self.main_file_path) .args(&self.get_data().cli_args) .output() diff --git a/src/interpreters/CSharp_original.rs b/src/interpreters/CSharp_original.rs index ff3c4aa..ddb7d99 100644 --- a/src/interpreters/CSharp_original.rs +++ b/src/interpreters/CSharp_original.rs @@ -128,7 +128,8 @@ impl Interpreter for CSharp_original { .expect("Unable to write to file for csharp-original"); //compile it (to the bin_path that arleady points to the rigth path) - let output = Command::new(&self.compiler) + let output = Command::new(self.compiler.split_whitespace().next().unwrap()) + .args(self.compiler.split_whitespace().skip(1)) .arg(String::from("-out:") + &self.bin_path) .arg(&self.main_file_path) .output() diff --git a/src/interpreters/C_original.rs b/src/interpreters/C_original.rs index 94ea304..86dfbcd 100644 --- a/src/interpreters/C_original.rs +++ b/src/interpreters/C_original.rs @@ -179,8 +179,9 @@ impl Interpreter for C_original { let mut _file = File::create(&self.main_file_path).expect("Failed to create file for c-original"); write(&self.main_file_path, &self.code).expect("Unable to write to file for c-original"); - let mut cmd = Command::new(&self.compiler); + let mut cmd = Command::new(self.compiler.split_whitespace().next().unwrap()); let cmd = cmd + .args(self.compiler.split_whitespace().skip(1)) .arg(&self.main_file_path) .arg("-o") .arg(&self.bin_path) diff --git a/src/interpreters/Clojure_fifo.rs b/src/interpreters/Clojure_fifo.rs index cd36872..c6cf97d 100644 --- a/src/interpreters/Clojure_fifo.rs +++ b/src/interpreters/Clojure_fifo.rs @@ -213,7 +213,9 @@ impl Interpreter for Clojure_fifo { Ok(()) } fn execute(&mut self) -> Result { - let output = Command::new(self.interpreter.clone()) + + let output = Command::new(self.interpreter.split_whitespace().next().unwrap()) + .args(self.interpreter.split_whitespace().skip(1)) .arg(&self.main_file_path) .args(&self.get_data().cli_args) .output() diff --git a/src/interpreters/D_original.rs b/src/interpreters/D_original.rs index 2b90adb..eb48d9a 100644 --- a/src/interpreters/D_original.rs +++ b/src/interpreters/D_original.rs @@ -91,7 +91,8 @@ impl Interpreter for D_original { fn execute(&mut self) -> Result { //run th binary and get the std output (or stderr) let interpreter = D_original::get_interpreter_or(&self.data, "dmd"); - let output = Command::new(interpreter) + let output = Command::new(interpreter.split_whitespace().next().unwrap()) + .args(interpreter.split_whitespace().skip(1)) .arg("-run") .arg(&self.main_file_path) .output() diff --git a/src/interpreters/Elixir_original.rs b/src/interpreters/Elixir_original.rs index eedeca3..789e299 100644 --- a/src/interpreters/Elixir_original.rs +++ b/src/interpreters/Elixir_original.rs @@ -165,7 +165,8 @@ impl Interpreter for Elixir_original { } fn execute(&mut self) -> Result { let interpreter = Elixir_original::get_interpreter_or(&self.data, "elixir"); - let output = Command::new(interpreter) + let output = Command::new(interpreter.split_whitespace().next().unwrap()) + .args(interpreter.split_whitespace().skip(1)) .arg(&self.main_file_path) .args(&self.get_data().cli_args) .output() diff --git a/src/interpreters/Go_original.rs b/src/interpreters/Go_original.rs index 5efa5fa..0ac019a 100644 --- a/src/interpreters/Go_original.rs +++ b/src/interpreters/Go_original.rs @@ -236,7 +236,8 @@ impl Interpreter for Go_original { write(&self.main_file_path, &self.code).expect("Unable to write to file for go-original"); //compile it (to the bin_path that arleady points to the rigth path) - let output = Command::new(&self.compiler) + let output = Command::new(self.compiler.split_whitespace().next().unwrap()) + .args(self.compiler.split_whitespace().skip(1)) .arg("build") .arg("-o") .arg(&self.go_work_dir) diff --git a/src/interpreters/Haskell_original.rs b/src/interpreters/Haskell_original.rs index d8d5e6c..8280dbe 100644 --- a/src/interpreters/Haskell_original.rs +++ b/src/interpreters/Haskell_original.rs @@ -106,7 +106,8 @@ impl Interpreter for Haskell_original { &self.main_file_path, &self.bin_path ); let compiler = Haskell_original::get_compiler_or(&self.data, "ghc"); - let output = Command::new(compiler) + let output = Command::new(compiler.split_whitespace().next().unwrap()) + .args(compiler.split_whitespace().skip(1)) .arg("-dynamic") .arg("-o") .arg(self.bin_path.clone()) diff --git a/src/interpreters/JS_TS_bun.rs b/src/interpreters/JS_TS_bun.rs index 0f2dad2..2e7e3ab 100644 --- a/src/interpreters/JS_TS_bun.rs +++ b/src/interpreters/JS_TS_bun.rs @@ -195,7 +195,8 @@ impl Interpreter for JS_TS_bun { } } let interpreter = JS_TS_bun::get_interpreter_or(&self.data, "bun"); - let output = Command::new(interpreter) + let output = Command::new(interpreter.split_whitespace().next().unwrap()) + .args(interpreter.split_whitespace().skip(1)) .arg("run") .arg("--silent") .args(bun_opts.split_whitespace()) diff --git a/src/interpreters/JS_TS_deno.rs b/src/interpreters/JS_TS_deno.rs index 8724846..f30f1a4 100644 --- a/src/interpreters/JS_TS_deno.rs +++ b/src/interpreters/JS_TS_deno.rs @@ -214,7 +214,8 @@ impl Interpreter for JS_TS_deno { fn execute(&mut self) -> Result { //run the binary and get the std output (or stderr) let interpreter = JS_TS_deno::get_interpreter_or(&self.data, "deno"); - let output = Command::new(interpreter) + let output = Command::new(interpreter.split_whitespace().next().unwrap()) + .args(interpreter.split_whitespace().skip(1)) .arg("run") .arg("-A") .arg("--unstable") diff --git a/src/interpreters/JS_original.rs b/src/interpreters/JS_original.rs index ff270fe..b7d7cae 100644 --- a/src/interpreters/JS_original.rs +++ b/src/interpreters/JS_original.rs @@ -94,7 +94,8 @@ impl Interpreter for JS_original { fn execute(&mut self) -> Result { let interpreter = JS_original::get_interpreter_or(&self.data, "node"); - let output = Command::new(interpreter) + let output = Command::new(interpreter.split_whitespace().next().unwrap()) + .args(interpreter.split_whitespace().skip(1)) .arg(&self.main_file_path) .args(&self.get_data().cli_args) .output() diff --git a/src/interpreters/Java_original.rs b/src/interpreters/Java_original.rs index 908e55f..0f4db95 100644 --- a/src/interpreters/Java_original.rs +++ b/src/interpreters/Java_original.rs @@ -102,7 +102,8 @@ impl Interpreter for Java_original { let compiler = Java_original::get_compiler_or(&self.data, "javac"); //compile it (to the bin_path that arleady points to the rigth path) - let output = Command::new(compiler) + let output = Command::new(compiler.split_whitespace().next().unwrap()) + .args(compiler.split_whitespace().skip(1)) .arg("-d") .arg(&self.java_work_dir) .arg(&self.main_file_path) diff --git a/src/interpreters/Julia_original.rs b/src/interpreters/Julia_original.rs index f2a3ddb..2a79353 100644 --- a/src/interpreters/Julia_original.rs +++ b/src/interpreters/Julia_original.rs @@ -180,7 +180,8 @@ impl Interpreter for Julia_original { Ok(()) } fn execute(&mut self) -> Result { - let output = Command::new(&self.interpreter) + let output = Command::new(self.interpreter.split_whitespace().next().unwrap()) + .args(self.interpreter.split_whitespace().skip(1)) .args(&self.interpreter_args) .arg(&self.main_file_path) .args(&self.get_data().cli_args) diff --git a/src/interpreters/Lua_original.rs b/src/interpreters/Lua_original.rs index cfc2890..b38f8b8 100644 --- a/src/interpreters/Lua_original.rs +++ b/src/interpreters/Lua_original.rs @@ -108,7 +108,8 @@ impl Interpreter for Lua_original { fn execute(&mut self) -> Result { let interpreter = Lua_original::get_interpreter_or(&self.data, "lua"); - let output = Command::new(interpreter) + let output = Command::new(interpreter.split_whitespace().next().unwrap()) + .args(interpreter.split_whitespace().skip(1)) .arg(&self.main_file_path) .args(&self.get_data().cli_args) .output() diff --git a/src/interpreters/Mathematica_original.rs b/src/interpreters/Mathematica_original.rs index db92de9..f0d43a5 100644 --- a/src/interpreters/Mathematica_original.rs +++ b/src/interpreters/Mathematica_original.rs @@ -238,7 +238,8 @@ impl Interpreter for Mathematica_original { fn execute(&mut self) -> Result { //run th binary and get the std output (or stderr) let interpreter = Mathematica_original::get_interpreter_or(&self.data, "WolframKernel"); - let output = Command::new(interpreter) + let output = Command::new(interpreter.split_whitespace().next().unwrap()) + .args(interpreter.split_whitespace().skip(1)) .arg("-noprompt") .arg("-script") .arg(&self.main_file_path) diff --git a/src/interpreters/Python3_original.rs b/src/interpreters/Python3_original.rs index e667912..e0a6ffc 100644 --- a/src/interpreters/Python3_original.rs +++ b/src/interpreters/Python3_original.rs @@ -243,7 +243,8 @@ impl Interpreter for Python3_original { Ok(()) } fn execute(&mut self) -> Result { - let output = Command::new(&self.interpreter) + let output = Command::new(self.interpreter.split_whitespace().next().unwrap()) + .args(self.interpreter.split_whitespace().skip(1)) .arg(&self.main_file_path) .args(&self.get_data().cli_args) .output() diff --git a/src/interpreters/R_original.rs b/src/interpreters/R_original.rs index 0b8c3f6..ce0bec0 100644 --- a/src/interpreters/R_original.rs +++ b/src/interpreters/R_original.rs @@ -97,7 +97,8 @@ impl Interpreter for R_original { fn execute(&mut self) -> Result { let interpreter = R_original::get_interpreter_or(&self.data, "Rscript"); - let output = Command::new(interpreter) + let output = Command::new(interpreter.split_whitespace().next().unwrap()) + .args(interpreter.split_whitespace().skip(1)) .arg(&self.main_file_path) .args(&self.get_data().cli_args) .output() diff --git a/src/interpreters/Ruby_original.rs b/src/interpreters/Ruby_original.rs index 4fb8daf..5c44fce 100644 --- a/src/interpreters/Ruby_original.rs +++ b/src/interpreters/Ruby_original.rs @@ -94,7 +94,8 @@ impl Interpreter for Ruby_original { fn execute(&mut self) -> Result { let interpreter = Ruby_original::get_interpreter_or(&self.data, "ruby"); - let output = Command::new(interpreter) + let output = Command::new(interpreter.split_whitespace().next().unwrap()) + .args(interpreter.split_whitespace().skip(1)) .arg(&self.main_file_path) .args(&self.get_data().cli_args) .output() diff --git a/src/interpreters/Rust_original.rs b/src/interpreters/Rust_original.rs index 4247d1a..206b856 100644 --- a/src/interpreters/Rust_original.rs +++ b/src/interpreters/Rust_original.rs @@ -122,8 +122,8 @@ impl Interpreter for Rust_original { write(&self.main_file_path, &self.code).expect("Unable to write to file for rust-original"); //compile it (to the bin_path that arleady points to the rigth path) - let output = Command::new(&self.compiler) - .arg("-O") + let output = Command::new(self.compiler.split_whitespace().next().unwrap()) + .args(self.compiler.split_whitespace().skip(1)) .arg("--out-dir") .arg(&self.rust_work_dir) .arg(&self.main_file_path) diff --git a/src/interpreters/Scala_original.rs b/src/interpreters/Scala_original.rs index 0ad7fdb..ce0c7c3 100644 --- a/src/interpreters/Scala_original.rs +++ b/src/interpreters/Scala_original.rs @@ -112,7 +112,8 @@ impl Interpreter for Scala_original { let compiler = Scala_original::get_compiler_or(&self.data, "scalac"); //compile it (to the bin_path that arleady points to the rigth path) - let output = Command::new(compiler) + let output = Command::new(compiler.split_whitespace().next().unwrap()) + .args(compiler.split_whitespace().skip(1)) .arg("-d") .arg(&self.language_work_dir) .arg(&self.main_file_path) diff --git a/src/interpreters/TypeScript_original.rs b/src/interpreters/TypeScript_original.rs index 5b82896..79d27de 100644 --- a/src/interpreters/TypeScript_original.rs +++ b/src/interpreters/TypeScript_original.rs @@ -113,7 +113,8 @@ impl Interpreter for TypeScript_original { fn execute(&mut self) -> Result { //run th binary and get the std output (or stderr) let interpreter = TypeScript_original::get_interpreter_or(&self.data, "ts-node"); - let output = Command::new(interpreter) + let output = Command::new(interpreter.split_whitespace().next().unwrap()) + .args(interpreter.split_whitespace().skip(1)) .arg(&self.main_file_path) .output() .expect("Unable to start process");