mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 06:20:09 +01:00
fix: builtin commands
This commit is contained in:
parent
8acb40af95
commit
09217fb179
3 changed files with 23 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -967,6 +967,7 @@ dependencies = [
|
|||
"askama",
|
||||
"colored",
|
||||
"inquire",
|
||||
"itertools 0.14.0",
|
||||
"pay-respects-parser",
|
||||
"pay-respects-utils",
|
||||
"regex-lite",
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ inquire = "0.7"
|
|||
|
||||
pay-respects-parser = { version = "0.3", path = "../parser" }
|
||||
pay-respects-utils = { version ="0.1", path = "../utils"}
|
||||
itertools = "0.14.0"
|
||||
|
||||
[package.metadata.deb]
|
||||
assets = [
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use pay_respects_utils::files::get_path_files;
|
|||
use pay_respects_utils::files::path_env_sep;
|
||||
|
||||
use askama::Template;
|
||||
use itertools::Itertools;
|
||||
|
||||
use std::process::{exit, Stdio};
|
||||
|
||||
|
|
@ -63,7 +64,7 @@ impl Data {
|
|||
let command = last_command(&shell).trim().to_string();
|
||||
let alias = alias_map(&shell);
|
||||
let mode = run_mode();
|
||||
let (executables, modules, fallbacks);
|
||||
let (mut executables, modules, fallbacks);
|
||||
let lib_dir = {
|
||||
if let Ok(lib_dir) = std::env::var("_PR_LIB") {
|
||||
Some(lib_dir)
|
||||
|
|
@ -150,6 +151,10 @@ impl Data {
|
|||
};
|
||||
}
|
||||
|
||||
let builtins = builtin_commands(&shell);
|
||||
executables.extend(builtins.clone());
|
||||
executables = executables.iter().unique().cloned().collect();
|
||||
|
||||
let mut init = Data {
|
||||
shell,
|
||||
env: None,
|
||||
|
|
@ -612,6 +617,21 @@ pub fn get_shell() -> String {
|
|||
}
|
||||
}
|
||||
|
||||
fn builtin_commands(shell: &str) -> Vec<String> {
|
||||
// TODO: add the commands for each shell
|
||||
// these should cover most of the builtin commands
|
||||
// (maybe with false positives)
|
||||
let builtin = vec![
|
||||
"alias", "bg", "bind", "break", "builtin", "case", "cd", "command", "compgen", "complete",
|
||||
"continue", "declare", "dirs", "disown", "echo", "enable", "eval", "exec", "exit",
|
||||
"export", "fc", "fg", "getopts", "hash", "help", "history", "if", "jobs", "kill", "let",
|
||||
"local", "logout", "popd", "printf", "pushd", "pwd", "read", "readonly", "return", "set",
|
||||
"shift", "shopt", "source", "suspend", "test", "times", "trap", "type", "typeset",
|
||||
"ulimit", "umask", "unalias", "unset", "until", "wait", "while", "which",
|
||||
];
|
||||
builtin.iter().map(|&cmd| cmd.to_string()).collect()
|
||||
}
|
||||
|
||||
pub fn shell_syntax(shell: &str, command: &str) -> String {
|
||||
#[allow(clippy::single_match)]
|
||||
match shell {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue