forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#66512 - jsgf:process-argv0, r=Dylan-DPC
Add unix::process::CommandExt::arg0 This allows argv[0] to be overridden on the executable's command-line. This also makes the program executed independent of argv[0]. Does Fuchsia have the same semantics? I'm assuming so. Addresses: rust-lang#66510
- Loading branch information
Showing
5 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// run-pass | ||
|
||
// ignore-windows - this is a unix-specific test | ||
// ignore-cloudabi no processes | ||
// ignore-emscripten no processes | ||
// ignore-sgx no processes | ||
#![feature(process_set_argv0)] | ||
|
||
use std::env; | ||
use std::os::unix::process::CommandExt; | ||
use std::process::Command; | ||
|
||
fn main() { | ||
let args: Vec<_> = env::args().collect(); | ||
|
||
if args.len() > 1 { | ||
assert_eq!(args[1], "doing-test"); | ||
assert_eq!(args[0], "i have a silly name"); | ||
|
||
println!("passed"); | ||
return; | ||
} | ||
|
||
let output = | ||
Command::new(&args[0]).arg("doing-test").arg0("i have a silly name").output().unwrap(); | ||
assert!( | ||
output.stderr.is_empty(), | ||
"Non-empty stderr: {}", | ||
String::from_utf8_lossy(&output.stderr) | ||
); | ||
assert!(output.status.success()); | ||
assert_eq!(output.stdout, b"passed\n"); | ||
} |