pwdx is part of procps - moved https://github.com/uutils/procps
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
[package]
|
||||
name = "uu_pwdx"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
uucore = { workspace = true }
|
||||
clap = { workspace = true }
|
||||
|
||||
[lib]
|
||||
path = "src/pwdx.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "pwdx"
|
||||
path = "src/main.rs"
|
||||
@@ -1,7 +0,0 @@
|
||||
# pwdx
|
||||
|
||||
```
|
||||
pwdx [options] pid [...]
|
||||
```
|
||||
|
||||
Report current working directory of a process
|
||||
@@ -1 +0,0 @@
|
||||
uucore::bin!(uu_pwdx);
|
||||
@@ -1,52 +0,0 @@
|
||||
// This file is part of the uutils util-linux package.
|
||||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
use clap::Arg;
|
||||
use clap::{crate_version, Command};
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::process;
|
||||
|
||||
use uucore::{error::UResult, format_usage, help_about, help_usage};
|
||||
|
||||
const ABOUT: &str = help_about!("pwdx.md");
|
||||
const USAGE: &str = help_usage!("pwdx.md");
|
||||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
|
||||
let matches = uu_app().try_get_matches_from(args)?;
|
||||
|
||||
let pid_str = matches.get_one::<String>("pid").unwrap();
|
||||
let pid = pid_str.parse::<i32>().unwrap_or_else(|_| {
|
||||
eprintln!("Invalid PID");
|
||||
process::exit(1);
|
||||
});
|
||||
|
||||
let cwd_link = format!("/proc/{}/cwd", pid);
|
||||
|
||||
match fs::read_link(Path::new(&cwd_link)) {
|
||||
Ok(path) => println!("{}: {}", pid, path.display()),
|
||||
Err(e) => {
|
||||
eprintln!("pwdx: failed to read link for PID {}: {}", pid, e);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn uu_app() -> Command {
|
||||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(ABOUT)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
.arg(Arg::new("pid")
|
||||
.value_name("PID")
|
||||
.help("Process ID")
|
||||
.required(true)
|
||||
.index(1))
|
||||
}
|
||||
Reference in New Issue
Block a user