mirror of
https://github.com/Xe/xn--ts9h
synced 2024-11-12 20:27:11 +00:00
check for argc==0
I thought that the kernel fixed that and made argc==0 invalid. Guess what. Some random programs rely on argc==0 so I have to handle it. Argh. Closes #5 Signed-off-by: Xe <me@christine.website>
This commit is contained in:
parent
b40ab778ea
commit
8f1dda8e53
4 changed files with 13 additions and 7 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -142,7 +142,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|||
|
||||
[[package]]
|
||||
name = "xn--ts9h"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"syslog",
|
||||
]
|
||||
|
|
|
@ -3,7 +3,7 @@ name = "xn--ts9h"
|
|||
description = "A simpler sudo command, named xn--ts9h because I can't use an emoji in the package name"
|
||||
license = "MIT"
|
||||
authors = [ "Xe Iaso <me@xeiaso.net>" ]
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
edition = "2021"
|
||||
|
||||
[package.metadata.deb]
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
packages = rec {
|
||||
bin = pkgs.rustPlatform.buildRustPackage {
|
||||
pname = "xn--ts9h";
|
||||
version = "0.1.1";
|
||||
version = "0.1.2";
|
||||
|
||||
inherit src;
|
||||
|
||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -1,16 +1,22 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
use std::{env, io, os::unix::process::CommandExt, process::Command, ffi::OsString};
|
||||
use std::{env, ffi::OsString, io, os::unix::process::CommandExt, process::Command};
|
||||
use syslog::{unix, Facility::LOG_AUTH, Formatter3164};
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
if env::args_os().nth(0).unwrap() != "🥺" {
|
||||
eprintln!("error: called 🥺 with name {:?}", env::args_os().nth(0).unwrap());
|
||||
eprintln!(
|
||||
"error: called 🥺 with name {:?}",
|
||||
env::args_os().nth(0).unwrap()
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if env::args_os().len() == 1 {
|
||||
eprintln!("usage: {:?} <command> [args]", env::args_os().nth(0).unwrap());
|
||||
if env::args_os().len() == 1 || env::args_os().len() == 0 {
|
||||
eprintln!(
|
||||
"usage: {:?} <command> [args]",
|
||||
env::args_os().nth(0).unwrap()
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue