diff --git a/src/lib/builtins/mod.rs b/src/lib/builtins/mod.rs index 6abaf6db2809062894c7324b9a850185b41ff585..57c644debb2826c243cb3ae9c7862b0a7c789a37 100644 --- a/src/lib/builtins/mod.rs +++ b/src/lib/builtins/mod.rs @@ -38,7 +38,7 @@ use hashbrown::HashMap; use liner::{Completer, Context}; use crate::{ - shell::{self, directory_stack::parse_numeric_arg, status::*, ProcessState, Shell}, + shell::{self, status::*, ProcessState, Shell}, sys, types, }; use itertools::Itertools; @@ -64,6 +64,17 @@ macro_rules! map { }}; } +// parses -N or +N patterns +// required for popd, pushd, dirs +fn parse_numeric_arg(arg: &str) -> Option<(bool, usize)> { + match arg.chars().nth(0) { + Some('+') => Some(true), + Some('-') => Some(false), + _ => None, + } + .and_then(|b| arg[1..].parse::<usize>().ok().map(|num| (b, num))) +} + /// A container for builtins and their respective help text /// /// Note: To reduce allocations, function are provided as pointer rather than boxed closures diff --git a/src/lib/lib.rs b/src/lib/lib.rs index 270e8873be68e34277d8dc3501066106c63fb798..5ff9351307e2db060740a28e13b98e88bfdcc599 100644 --- a/src/lib/lib.rs +++ b/src/lib/lib.rs @@ -16,4 +16,7 @@ mod memory; mod shell; pub(crate) use self::memory::IonPool; -pub use crate::shell::*; +pub use crate::{ + builtins::{BuiltinFunction, BuiltinMap}, + shell::*, +}; diff --git a/src/lib/shell/directory_stack.rs b/src/lib/shell/directory_stack.rs index efff71ad1c407cd076b5184da53a72888d9d7de2..0b677ff9849fd55b69736e6c4137d78e07f9ca4a 100644 --- a/src/lib/shell/directory_stack.rs +++ b/src/lib/shell/directory_stack.rs @@ -227,14 +227,3 @@ impl DirectoryStack { DirectoryStack { dirs } } } - -// parses -N or +N patterns -// required for popd, pushd, dirs -pub fn parse_numeric_arg(arg: &str) -> Option<(bool, usize)> { - match arg.chars().nth(0) { - Some('+') => Some(true), - Some('-') => Some(false), - _ => None, - } - .and_then(|b| arg[1..].parse::<usize>().ok().map(|num| (b, num))) -} diff --git a/src/lib/shell/mod.rs b/src/lib/shell/mod.rs index f3f939242ac374df7cda1f9b94e53ae9038118ad..373de69af8b212c4dcd949c22beb50e19a49e271 100644 --- a/src/lib/shell/mod.rs +++ b/src/lib/shell/mod.rs @@ -12,18 +12,13 @@ pub(crate) mod signals; pub mod status; pub mod variables; -pub use self::{ - fork::{Capture, IonResult}, - job::Job, - pipe_exec::job_control::ProcessState, - variables::Value, -}; +pub use self::{fork::Capture, job::Job, pipe_exec::job_control::ProcessState, variables::Value}; use self::{ directory_stack::DirectoryStack, flow_control::{Block, Function, FunctionError, Statement}, foreground::ForegroundSignals, - fork::Fork, + fork::{Fork, IonResult}, pipe_exec::{foreground, job_control::BackgroundProcess}, status::*, variables::{GetVariable, Variables},