| #!/bin/ruby | ||
| puts "hello world!" |
| #!/bin/ruby | ||
| puts ARGV.inspect | ||
| puts ARGV.length |
| { | ||
| "git": { | ||
| "sha1": "1170c2d81e4b7f791affd2f5c8e1020833b084b9" | ||
| "sha1": "e0b4d421c346396d1431b44637d9453b2674a15a" | ||
| } | ||
| } |
+1
-1
@@ -16,3 +16,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO | ||
| name = "rshc" | ||
| version = "0.1.1" | ||
| version = "0.1.2" | ||
| authors = ["Yukang <moorekang@gmail.com>"] | ||
@@ -19,0 +19,0 @@ description = "rshc: Rust compile shell script(or expect script) to Rust code and binary." |
+35
-4
@@ -1,9 +0,40 @@ | ||
| # rsh | ||
| # rshc | ||
| Rust compile shell script(or expect script) to Rust code and binary. | ||
| rshc: Compile shell script(or expect script) to Rust code and binary. | ||
| Usage: | ||
| Rshc takes a script, which is specified on the command line and produces Rust source code. | ||
| The generated source code is then compiled and linked to produce a stripped binary executable, which use the Rust compiler. | ||
| Actual execution will use process to exec the script, the but source code of script is encoded in binary with Rc4 algorithm. | ||
| This is used as: | ||
| 1. For the expect script which maybe contains some password, I will compile binary and remove the script. | ||
| 2. For some scripts which I want to add password for it. | ||
| ## Install | ||
| You need also install rustc, because rshc will use rustc to compile to binary. | ||
| 1. Install rustc if you didn't installed: | ||
| ```bash | ||
| curl https://sh.rustup.rs -sSf | sh | ||
| ``` | ||
| 2. install the rshc cli app: | ||
| ```bash | ||
| cargo install rshc | ||
| ``` | ||
| ## Usage | ||
| ```rust | ||
| rsh -f demo.sh -o demo.rs | ||
| rshc -f demo.sh -o demo.rs | ||
| // add a passowrd when compile it, then binary will prompt for correct password before execution | ||
| rshc -f demo.sh -o demo.rs -p | ||
| ``` | ||
@@ -10,0 +41,0 @@ |
+3
-2
@@ -78,4 +78,5 @@ extern crate clap; | ||
| //println!("{}", prog); | ||
| let opt = if iterp == "ruby" { "-e" } else { "-c" }; | ||
| let output = Command::new(iterp) | ||
| .arg("-c") | ||
| .arg(opt) | ||
| .arg(prog) | ||
@@ -115,3 +116,3 @@ .args(args) | ||
| let mut args = env::args().collect::<Vec<_>>(); | ||
| args[0] = String::from(""); | ||
| args.drain(0..1); | ||
| run_process(&iterp.to_string(), &prog_str, &args); | ||
@@ -118,0 +119,0 @@ } |
Sorry, the diff of this file is not supported yet