Skip to content

Commit f869267

Browse files
author
geno
committed
Re-execute command every iteration
1 parent 0724e46 commit f869267

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Cargo.lock

+1-1
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 = "watchdiff"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
authors = ["geno nullfree <[email protected]>"]
55
license = "BSD-3-Clause"
66
description = "A small utility to diff watch output"

src/main.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ enum PrintType {
2323
Del,
2424
}
2525

26+
const BASH: &str = "/bin/bash";
27+
const C: &str = "-c";
28+
2629
fn main() {
2730
// Process arguments
2831
let opt = Opt::from_args();
@@ -44,14 +47,22 @@ fn do_watchdiff(opt: Opt) {
4447
println!("{}", banner.bold().underline());
4548

4649
// Setup command and arguments
47-
let mut raw = Command::new(&opt.command[0]);
48-
let cmd = raw.args(&opt.command[1..]);
50+
let mut raw = Command::new(BASH);
51+
let mut args = vec![C];
52+
for c in &opt.command {
53+
args.push(c);
54+
}
55+
let cmd = raw.args(&args);
4956

5057
// Run initial command
5158
let mut out = run_command(cmd);
5259
println!("{}", out);
5360

5461
loop {
62+
// Re-setup command and arguments
63+
let mut raw = Command::new(BASH);
64+
let cmd = raw.args(&args);
65+
5566
// Run command update
5667
let diff = run_command(cmd);
5768

0 commit comments

Comments
 (0)