Handle empty std::env::args() for FreeBSD. (fixes #75)
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
84ce3e0d0e
commit
56d9c9a8b5
1 changed files with 9 additions and 10 deletions
|
|
@ -35,21 +35,20 @@ pub(super) fn version(args: TokenStream) -> TokenStream {
|
|||
return args;
|
||||
};
|
||||
|
||||
let rustc_path = std::env::args()
|
||||
.next()
|
||||
.expect("Path to rustc executable");
|
||||
|
||||
let version = Command::new(rustc_path)
|
||||
.args(["-V"])
|
||||
.output()
|
||||
.map(|output| {
|
||||
let rustc_path = std::env::args().next();
|
||||
let version = rustc_path
|
||||
.and_then(|rustc_path| {
|
||||
Command::new(rustc_path)
|
||||
.args(["-V"])
|
||||
.output()
|
||||
.ok()
|
||||
})
|
||||
.and_then(|output| {
|
||||
str::from_utf8(&output.stdout)
|
||||
.map(str::trim)
|
||||
.map(String::from)
|
||||
.ok()
|
||||
})
|
||||
.ok()
|
||||
.flatten()
|
||||
.unwrap_or_default();
|
||||
|
||||
let ret = quote! {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue