mirror of
https://github.com/Xe/xn--ts9h
synced 2024-11-13 20:57:07 +00:00
Fix crash when calling a command with a name like rÿd
This commit is contained in:
parent
aa6976cd03
commit
5544689321
1 changed files with 5 additions and 5 deletions
10
src/main.rs
10
src/main.rs
|
@ -1,21 +1,21 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
use std::{env, io, os::unix::process::CommandExt, process::Command};
|
||||
use std::{env, io, os::unix::process::CommandExt, process::Command, ffi::OsString};
|
||||
use syslog::{unix, Facility::LOG_AUTH, Formatter3164};
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
if env::args().nth(0).unwrap() != "🥺" {
|
||||
if env::args_os().nth(0).unwrap() != "🥺" {
|
||||
eprintln!("error: called 🥺 with name {}", env::args().nth(0).unwrap());
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if env::args().len() == 1 {
|
||||
if env::args_os().len() == 1 {
|
||||
eprintln!("usage: {} <command> [args]", env::args().nth(0).unwrap());
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let program = env::args().nth(1).unwrap();
|
||||
let args = env::args().skip(2).collect::<Vec<String>>();
|
||||
let program = env::args_os().nth(1).unwrap();
|
||||
let args = env::args_os().skip(2).collect::<Vec<OsString>>();
|
||||
let mut writer = unix(Formatter3164 {
|
||||
facility: LOG_AUTH,
|
||||
hostname: None,
|
||||
|
|
Loading…
Reference in a new issue