mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 06:20:09 +01:00
fix: use ; as delimiter on windows for _PR_LIB (github #37)
Co-authored-by: iff <iff@ik.me>
This commit is contained in:
parent
737440869c
commit
d76a244a1a
3 changed files with 22 additions and 5 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
use pay_respects_utils::evals::split_command;
|
use pay_respects_utils::evals::split_command;
|
||||||
use pay_respects_utils::files::get_path_files;
|
use pay_respects_utils::files::get_path_files;
|
||||||
|
use pay_respects_utils::files::path_env_sep;
|
||||||
|
|
||||||
use std::process::{exit, Stdio};
|
use std::process::{exit, Stdio};
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
@ -7,6 +9,9 @@ use std::sync::mpsc::channel;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
use pay_respects_utils::files::path_convert;
|
||||||
|
|
||||||
pub const PRIVILEGE_LIST: [&str; 2] = ["sudo", "doas"];
|
pub const PRIVILEGE_LIST: [&str; 2] = ["sudo", "doas"];
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
|
|
@ -112,8 +117,12 @@ impl Data {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = lib_dir.split(':').collect::<Vec<&str>>();
|
let path = lib_dir.split(path_env_sep()).collect::<Vec<&str>>();
|
||||||
|
|
||||||
for p in path {
|
for p in path {
|
||||||
|
#[cfg(windows)]
|
||||||
|
let p = path_convert(p);
|
||||||
|
|
||||||
let files = match std::fs::read_dir(p) {
|
let files = match std::fs::read_dir(p) {
|
||||||
Ok(files) => files,
|
Ok(files) => files,
|
||||||
Err(_) => continue,
|
Err(_) => continue,
|
||||||
|
|
|
||||||
10
modules.md
10
modules.md
|
|
@ -51,7 +51,7 @@ Expose your module as executable (`chmod u+x`) in `PATH`, and done!
|
||||||
|
|
||||||
## `LIB` directories
|
## `LIB` directories
|
||||||
|
|
||||||
If exposing modules in `PATH` annoys you, you can set the `_PR_LIB` environment variable to specify directories to find the modules, separated by `:` (analogous to `PATH`):
|
If exposing modules in `PATH` annoys you, you can set the `_PR_LIB` environment variable to specify directories to find the modules, separated by `:` or `;` (analogous to `PATH`):
|
||||||
|
|
||||||
Example in a [FHS 3.0 compliant system](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s06.html):
|
Example in a [FHS 3.0 compliant system](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s06.html):
|
||||||
```shell
|
```shell
|
||||||
|
|
@ -60,6 +60,14 @@ export _DEF_PR_LIB="/usr/lib"
|
||||||
# runtime
|
# runtime
|
||||||
export _PR_LIB="/usr/lib:$HOME/.local/share"
|
export _PR_LIB="/usr/lib:$HOME/.local/share"
|
||||||
```
|
```
|
||||||
|
Example in Windows/DOS compliant systems
|
||||||
|
```pwsh
|
||||||
|
$env:_PR_LIB = @(
|
||||||
|
(Join-Path $env:APPDATA "pay-respects" "modules"),
|
||||||
|
(Join-Path $env:USERPROFILE ".cargo" "bin")
|
||||||
|
) -join ';'
|
||||||
|
```
|
||||||
|
|
||||||
This is not the default as there is no general way to know its value and depends on distribution (`/usr/lib`, `/usr/libexec`, or NixOS which isn't FHS compliant at all). System programs usually have a hard-coded path looking for `lib`. If you are a package maintainer for a distribution, setting this value when compiling, so it fits into your distribution standard.
|
This is not the default as there is no general way to know its value and depends on distribution (`/usr/lib`, `/usr/libexec`, or NixOS which isn't FHS compliant at all). System programs usually have a hard-coded path looking for `lib`. If you are a package maintainer for a distribution, setting this value when compiling, so it fits into your distribution standard.
|
||||||
|
|
||||||
If you installed the module with `cargo install`, the binary will be placed in `bin` subdirectory under Cargo's home which should be in the `PATH` anyway. Cargo has no option to place in subdirectories with other names.
|
If you installed the module with `cargo install`, the binary will be placed in `bin` subdirectory under Cargo's home which should be in the `PATH` anyway. Cargo has no option to place in subdirectories with other names.
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ fn path_env() -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn path_env_sep() -> &'static str {
|
pub fn path_env_sep() -> &'static str {
|
||||||
if is_msystem() {
|
if is_msystem() {
|
||||||
":"
|
":"
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -132,7 +132,7 @@ fn path_env_sep() -> &'static str {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn path_convert(path: &str) -> String {
|
pub fn path_convert(path: &str) -> String {
|
||||||
if is_msystem() {
|
if is_msystem() {
|
||||||
msys2_conv_path(path).expect("Failed to convert path for msys")
|
msys2_conv_path(path).expect("Failed to convert path for msys")
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -164,6 +164,6 @@ fn path_env() -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
fn path_env_sep() -> &'static str {
|
pub fn path_env_sep() -> &'static str {
|
||||||
":"
|
":"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue