diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 73d4c8e611392c717508d1d37ac0bd69a4c6e007..350d22c5b2be703485c77d4189216bb1e1dbbdf1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,7 @@ cache: - target/ linux: - image: 'rust:1.28.0' + image: 'rust:1.30.0' script: - cargo build - make tests diff --git a/Makefile b/Makefile index 5229439ee8969655d70c93931d2ab7642a387f77..880eb57309339fd99deb8cd689e409489f7796aa 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ RELEASE = debug DEBUG ?= 0 VENDORED = 0 REDOX ?= 0 -TOOLCHAIN ?= 1.28.0 +TOOLCHAIN ?= 1.30.0 GIT_REVISION=git_revision.txt SRC=Cargo.toml src/* src/*/* members/* members/*/* diff --git a/README.md b/README.md index 29a282da7d61352508b3ba55153c4bc8abe98f2a..b0709aba2773228b6e088684f34f6f98e89e5836 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ with **mdbook**. ## Pop!\_OS / Ubuntu -The following PPA supports the 18.04 (bionic) and 18.10 (cosmic) releases. Bionic builds were made using the Pop\_OS PPA's rustc 1.28.0 package. +The following PPA supports the 18.04 (bionic) and 18.10 (cosmic) releases. Bionic builds were made using the Pop\_OS PPA's rustc 1.30.0 package. ``` sudo add-apt-repository ppa:mmstick76/ion-shell @@ -41,11 +41,11 @@ sudo add-apt-repository ppa:mmstick76/ion-shell # Build dependencies Those who are developing software with Rust should install the [Rustup toolchain manager](https://rustup.rs/). -After installing rustup, run `rustup default 1.28.0` to set your Rust toolchain to the version that Ion is +After installing rustup, run `rustup default 1.30.0` to set your Rust toolchain to the version that Ion is targeting at the moment. To build for Redox OS, `rustup default nightly` is required to build the Redox dependencies. -> Distribution packagers must ensure that their distribution has packaged both cargo and rustc 1.28.0. +> Distribution packagers must ensure that their distribution has packaged both cargo and rustc 1.30.0. > Distribution packagers should also currently build Ion from git. Release tarballs have not been made yet > due to the shell being incomplete in a few remaining areas. diff --git a/src/lib/builtins/command_info.rs b/src/lib/builtins/command_info.rs index 992c12b67fbc8099f33b66e12592eec0f28770a0..e5237d47c10bc3e07d161e94990b4fb531506b49 100644 --- a/src/lib/builtins/command_info.rs +++ b/src/lib/builtins/command_info.rs @@ -1,8 +1,9 @@ -use builtins::man_pages::*; -use shell::{flow_control::Function, status::*, Shell}; +use crate::{ + builtins::man_pages::*, + shell::{flow_control::Function, status::*, Shell}, + sys, types, +}; use small; -use sys; -use types; use std::{borrow::Cow, env, path::Path}; diff --git a/src/lib/builtins/exec.rs b/src/lib/builtins/exec.rs index 100c9d8ad9c0a2d0f409458b883dae69e55e34c4..c813b985fea53bab247e21005e87d220912e42aa 100644 --- a/src/lib/builtins/exec.rs +++ b/src/lib/builtins/exec.rs @@ -1,8 +1,10 @@ -use builtins::man_pages::{check_help, MAN_EXEC}; -use shell::Shell; +use crate::{ + builtins::man_pages::{check_help, MAN_EXEC}, + shell::Shell, + sys::execve, +}; use small; use std::error::Error; -use sys::execve; /// Executes the givent commmand. pub(crate) fn exec(shell: &mut Shell, args: &[small::String]) -> Result<(), small::String> { diff --git a/src/lib/builtins/exists.rs b/src/lib/builtins/exists.rs index e3b82572aa7fd24b9903145f5626f17991dd6a62..1f21ea34dcd1e49bb43fd78f05ce6e7dd44d2de7 100644 --- a/src/lib/builtins/exists.rs +++ b/src/lib/builtins/exists.rs @@ -1,10 +1,12 @@ use std::{fs, os::unix::fs::PermissionsExt}; #[cfg(test)] -use shell::{self, flow_control::Statement}; -use shell::{flow_control::Function, Shell}; +use crate::shell::{self, flow_control::Statement}; +use crate::{ + shell::{flow_control::Function, Shell}, + types, +}; use small; -use types; pub(crate) fn exists(args: &[small::String], shell: &Shell) -> Result<bool, small::String> { let arguments = &args[1..]; @@ -138,7 +140,7 @@ fn function_is_defined(function: &str, shell: &Shell) -> bool { #[test] fn test_evaluate_arguments() { - use lexers::assignments::{KeyBuf, Primitive}; + use crate::lexers::assignments::{KeyBuf, Primitive}; let mut shell = shell::ShellBuilder::new().as_library(); // assert_eq!(evaluate_arguments(&[], &mut sink, &shell), Ok(false)); @@ -348,7 +350,7 @@ fn test_string_var_is_not_empty() { #[test] fn test_function_is_defined() { - use lexers::assignments::{KeyBuf, Primitive}; + use crate::lexers::assignments::{KeyBuf, Primitive}; let mut shell = shell::ShellBuilder::new().as_library(); // create a simple dummy function diff --git a/src/lib/builtins/functions.rs b/src/lib/builtins/functions.rs index 63a832e21b9a138587e4c8f53bc153c4f3cd0ff4..7b59e4354cfbeec33eaa6759b6653a314f1f2056 100644 --- a/src/lib/builtins/functions.rs +++ b/src/lib/builtins/functions.rs @@ -1,4 +1,4 @@ -use shell::{status::*, variables::Variables}; +use crate::shell::{status::*, variables::Variables}; use std::io::{self, Write}; fn print_functions(vars: &Variables) { diff --git a/src/lib/builtins/is.rs b/src/lib/builtins/is.rs index 680826fa386950a5da5bb30f942ed7f8f6a47138..fae2ea4e0543180cbc57cef553caa9d8389f2bc0 100644 --- a/src/lib/builtins/is.rs +++ b/src/lib/builtins/is.rs @@ -1,6 +1,5 @@ -use shell::Shell; +use crate::{shell::Shell, types}; use small; -use types; pub(crate) fn is(args: &[small::String], shell: &mut Shell) -> Result<(), String> { match args.len() { @@ -47,7 +46,7 @@ fn test_is() { fn vec_string(args: &[&str]) -> Vec<small::String> { args.iter().map(|s| (*s).into()).collect() } - use shell::ShellBuilder; + use crate::shell::ShellBuilder; let mut shell = ShellBuilder::new().as_library(); shell.set("x", "value"); shell.set("y", "0"); diff --git a/src/lib/builtins/job_control.rs b/src/lib/builtins/job_control.rs index 0fa7425cf6c4f5f5a38c90752366efa08f32f129..8f9768deff4968d368c28fbb7377bb961b71a64e 100644 --- a/src/lib/builtins/job_control.rs +++ b/src/lib/builtins/job_control.rs @@ -1,7 +1,7 @@ //! Contains the `jobs`, `disown`, `bg`, and `fg` commands that manage job //! control in the shell. -use shell::{ +use crate::shell::{ job_control::{JobControl, ProcessState}, signals, status::*, diff --git a/src/lib/builtins/mod.rs b/src/lib/builtins/mod.rs index 1989df67caebcfe5daca1c943bff7495cdcdd04a..09d9748de633673ead08ba7c9c7e5ea01553b245 100644 --- a/src/lib/builtins/mod.rs +++ b/src/lib/builtins/mod.rs @@ -32,17 +32,18 @@ use std::{ io::{self, Write}, }; -use parser::Terminator; -use shell::{ - self, - fork_function::fork_function, - job_control::{JobControl, ProcessState}, - status::*, - FlowLogic, Shell, ShellHistory, +use crate::{ + parser::Terminator, + shell::{ + self, + fork_function::fork_function, + job_control::{JobControl, ProcessState}, + status::*, + FlowLogic, Shell, ShellHistory, + }, + sys, types, }; use small; -use sys; -use types; const HELP_DESC: &str = "Display helpful information about a given command or list commands if \ none specified\n help <command>"; diff --git a/src/lib/builtins/set.rs b/src/lib/builtins/set.rs index 6ffdb73545ebc747552571408dae15952cd75b84..36faf6aace8b524046dcec875c53122bfab4d3d1 100644 --- a/src/lib/builtins/set.rs +++ b/src/lib/builtins/set.rs @@ -1,8 +1,10 @@ +use crate::{ + shell::{flags::*, Shell}, + types, +}; use liner::KeyBindings; -use shell::{flags::*, Shell}; use small; use std::iter; -use types; enum PositionalArgs { UnsetIfNone, diff --git a/src/lib/builtins/source.rs b/src/lib/builtins/source.rs index 650e8c18db0290d8934120b90a56b306b8ff0733..a77388db8cd7c62bf3baf30f9685beda1e1ca951 100644 --- a/src/lib/builtins/source.rs +++ b/src/lib/builtins/source.rs @@ -1,4 +1,4 @@ -use shell::{FlowLogic, Shell}; +use crate::shell::{FlowLogic, Shell}; use small; use std::{fs::File, io::Read}; diff --git a/src/lib/builtins/status.rs b/src/lib/builtins/status.rs index ba4b683426ec01c2fc7eda22162488bd9e8c80aa..11879d3a07ed6bbdef54a89981aa2d15c7db7dd6 100644 --- a/src/lib/builtins/status.rs +++ b/src/lib/builtins/status.rs @@ -1,5 +1,4 @@ -use builtins::man_pages::MAN_STATUS; -use shell::Shell; +use crate::{builtins::man_pages::MAN_STATUS, shell::Shell}; use small; use std::env; diff --git a/src/lib/builtins/variables.rs b/src/lib/builtins/variables.rs index 7018ff7f4cac5b52b063dc4b8aaa330c4293a51a..77d9c7b3b8b304e447d26fa3e766c3186da5fe8a 100644 --- a/src/lib/builtins/variables.rs +++ b/src/lib/builtins/variables.rs @@ -2,8 +2,10 @@ use std::io::{self, Write}; -use shell::{status::*, variables::Variables}; -use types; +use crate::{ + shell::{status::*, variables::Variables}, + types, +}; fn print_list(vars: &Variables) { let stdout = io::stdout(); @@ -141,9 +143,11 @@ pub(crate) fn drop_variable<S: AsRef<str>>(vars: &mut Variables, args: &[S]) -> #[cfg(test)] mod test { use super::*; - use parser::{expand_string, Expander}; - use shell::status::{FAILURE, SUCCESS}; - use types::Array; + use crate::{ + parser::{expand_string, Expander}, + shell::status::{FAILURE, SUCCESS}, + types::Array, + }; struct VariableExpander(pub Variables); diff --git a/src/lib/lib.rs b/src/lib/lib.rs index 1d63a2ade68852946b7199c606cbd915ccf5929d..509d25d56961826e0bd908a820c1b1a7bf4f632f 100644 --- a/src/lib/lib.rs +++ b/src/lib/lib.rs @@ -33,7 +33,7 @@ mod ascii_helpers; mod builtins; pub mod shell; -pub use shell::{ +pub use crate::shell::{ binary::MAN_ION, flags, pipe_exec::job_control::JobControl, status, Binary, Capture, Fork, IonError, IonResult, Shell, ShellBuilder, }; diff --git a/src/lib/parser/assignments/actions.rs b/src/lib/parser/assignments/actions.rs index 5c386413c64c80fc97e1a88536da80236c259057..88ab7b6936cc70d36bff75fc57f238f36c4e0bfe 100644 --- a/src/lib/parser/assignments/actions.rs +++ b/src/lib/parser/assignments/actions.rs @@ -1,5 +1,5 @@ use super::checker::*; -use lexers::{ +use crate::lexers::{ assignments::{Key, KeyIterator, Operator, Primitive, TypeError}, ArgumentSplitter, }; @@ -152,7 +152,7 @@ impl<'a> Action<'a> { #[cfg(test)] mod tests { use super::*; - use lexers::assignments::*; + use crate::lexers::assignments::*; fn split(input: &str) -> (String, Operator, String) { let (keys, op, vals) = assignment_lexer(input); diff --git a/src/lib/parser/assignments/checker.rs b/src/lib/parser/assignments/checker.rs index 7165bb184ac479671fcd7ead4023081f71a83dda..682914f4e47c45d44aea9e0514061869ffe26c79 100644 --- a/src/lib/parser/assignments/checker.rs +++ b/src/lib/parser/assignments/checker.rs @@ -1,8 +1,10 @@ use super::super::{expand_string, Expander}; -use lexers::assignments::{Primitive, TypeError}; -use shell::variables::VariableType; +use crate::{ + lexers::assignments::{Primitive, TypeError}, + shell::variables::VariableType, + types, +}; use std::iter::Iterator; -use types; #[derive(PartialEq, Clone, Copy, Debug)] enum IsArrayHelper { @@ -280,7 +282,7 @@ pub(crate) fn value_check<E: Expander>( #[cfg(test)] mod test { use super::*; - use types::Array; + use crate::types::Array; #[test] fn is_array_() { diff --git a/src/lib/parser/loops.rs b/src/lib/parser/loops.rs index a2f068849e96924d7fcd4460fabfa35d2f1a19b7..2357e3b7e73acd465877ff4212ea75de5a259d4d 100644 --- a/src/lib/parser/loops.rs +++ b/src/lib/parser/loops.rs @@ -1,5 +1,7 @@ -use parser::{expand_string, Expander}; -use types; +use crate::{ + parser::{expand_string, Expander}, + types, +}; /// The expression given to a for loop as the value to iterate upon. pub(crate) enum ForValueExpression { @@ -17,7 +19,7 @@ impl ForValueExpression { if output.len() == 1 { let output = output.into_iter().next().unwrap(); - if let Some(range) = ::ranges::parse_range(&output) { + if let Some(range) = crate::ranges::parse_range(&output) { return ForValueExpression::Range(range); } diff --git a/src/lib/parser/pipelines/collector.rs b/src/lib/parser/pipelines/collector.rs index a1c28c6fa2f60befa125b26ed898d71596c51542..bc020a4fe2ea5eeae8a94fcb10033541c5d835ce 100644 --- a/src/lib/parser/pipelines/collector.rs +++ b/src/lib/parser/pipelines/collector.rs @@ -1,8 +1,10 @@ use std::{collections::HashSet, iter::Peekable}; use super::{Input, PipeItem, Pipeline, RedirectFrom, Redirection}; -use shell::{Job, JobKind}; -use types::*; +use crate::{ + shell::{Job, JobKind}, + types::*, +}; trait AddItem { fn add_item( @@ -453,12 +455,14 @@ impl<'a> Collector<'a> { #[cfg(test)] mod tests { - use parser::{ - pipelines::{Input, PipeItem, Pipeline, RedirectFrom, Redirection}, - statement::parse, + use crate::{ + parser::{ + pipelines::{Input, PipeItem, Pipeline, RedirectFrom, Redirection}, + statement::parse, + }, + shell::{flow_control::Statement, Job, JobKind}, + types::Array, }; - use shell::{flow_control::Statement, Job, JobKind}; - use types::Array; #[test] fn stderr_redirection() { diff --git a/src/lib/parser/pipelines/mod.rs b/src/lib/parser/pipelines/mod.rs index 72f0aec0242c52be0adb6c5d93b99a004d729871..921e14d9a37a1cd82a80abff706f619b1a172529 100644 --- a/src/lib/parser/pipelines/mod.rs +++ b/src/lib/parser/pipelines/mod.rs @@ -3,7 +3,7 @@ mod collector; pub(crate) use self::collector::*; use super::expand_string; -use shell::{pipe_exec::stdin_of, Job, JobKind, Shell}; +use crate::shell::{pipe_exec::stdin_of, Job, JobKind, Shell}; use small; use std::{fmt, fs::File, os::unix::io::FromRawFd}; diff --git a/src/lib/parser/shell_expand/mod.rs b/src/lib/parser/shell_expand/mod.rs index 1ed5af95f304afd6c133c43b5afe998e49decae1..374d9ca86f0c3ccdf9b7a00c0b64415a8f4dca4b 100644 --- a/src/lib/parser/shell_expand/mod.rs +++ b/src/lib/parser/shell_expand/mod.rs @@ -4,12 +4,14 @@ extern crate calc; mod words; pub(crate) use self::words::{Select, WordIterator, WordToken}; -use braces::{self, BraceToken}; +use crate::{ + braces::{self, BraceToken}, + ranges::{parse_range, Index, Range}, + types::{self, Array}, +}; use glob::glob; -use ranges::{parse_range, Index, Range}; use small; use std::{ptr, str}; -use types::{self, Array}; use unicode_segmentation::UnicodeSegmentation; /// Determines whether an input string is expression-like as compared to a @@ -31,17 +33,17 @@ pub type MapValueIter<'a> = Box<dyn Iterator<Item = types::Str> + 'a>; /// Trait representing different elements of string expansion pub(crate) trait Expander { /// Expand a tilde form to the correct directory. - fn tilde(&self, &str) -> Option<String> { None } + fn tilde(&self, _input: &str) -> Option<String> { None } /// Expand an array variable with some selection. - fn array(&self, &str, Select) -> Option<types::Array> { None } + fn array(&self, _name: &str, _selection: Select) -> Option<types::Array> { None } /// Expand a string variable given if it's quoted / unquoted - fn string(&self, &str, bool) -> Option<types::Str> { None } + fn string(&self, _name: &str, _quoted: bool) -> Option<types::Str> { None } /// Expand a subshell expression. - fn command(&self, &str) -> Option<types::Str> { None } + fn command(&self, _command: &str) -> Option<types::Str> { None } /// Iterating upon key-value maps. - fn map_keys<'a>(&'a self, &str, Select) -> Option<MapKeyIter> { None } + fn map_keys<'a>(&'a self, _name: &str, _select: Select) -> Option<MapKeyIter> { None } /// Iterating upon key-value maps. - fn map_values<'a>(&'a self, &str, Select) -> Option<MapValueIter> { None } + fn map_values<'a>(&'a self, _name: &str, _select: Select) -> Option<MapValueIter> { None } } fn expand_process<E: Expander>( diff --git a/src/lib/parser/shell_expand/words/methods/arrays.rs b/src/lib/parser/shell_expand/words/methods/arrays.rs index e86bc57787b099e7e7b127f91dd6e45c9405e9f1..6eb54cc83a2707b5e2a069594968e8dac54c2b08 100644 --- a/src/lib/parser/shell_expand/words/methods/arrays.rs +++ b/src/lib/parser/shell_expand/words/methods/arrays.rs @@ -6,10 +6,12 @@ use super::{ strings::unescape, Pattern, }; -use ranges::Index; +use crate::{ + ranges::Index, + types::{self, Array}, +}; use small; use std::char; -use types::{self, Array}; use unicode_segmentation::UnicodeSegmentation; #[derive(Debug, PartialEq, Clone)] @@ -217,8 +219,7 @@ impl<'a> ArrayMethod<'a> { #[cfg(test)] mod test { use super::*; - use ranges::Range; - use types; + use crate::{ranges::Range, types}; struct VariableExpander; diff --git a/src/lib/parser/shell_expand/words/methods/mod.rs b/src/lib/parser/shell_expand/words/methods/mod.rs index fb36e8cf39ebf395939e1a8416346484da404ad4..407d1f08bdfe04d8948d00f3c04c42ad4a641e70 100644 --- a/src/lib/parser/shell_expand/words/methods/mod.rs +++ b/src/lib/parser/shell_expand/words/methods/mod.rs @@ -5,7 +5,7 @@ use self::strings::unescape; pub(crate) use self::{arrays::ArrayMethod, strings::StringMethod}; use super::{expand_string, Expander}; -use lexers::ArgumentSplitter; +use crate::lexers::ArgumentSplitter; use small; #[derive(Debug, PartialEq, Clone)] diff --git a/src/lib/parser/shell_expand/words/methods/strings.rs b/src/lib/parser/shell_expand/words/methods/strings.rs index 48b30fe393e8782528776d708d696ee5e11c87bf..986f5e92ba6059aa8a0c74fb43c42a81e410e523 100644 --- a/src/lib/parser/shell_expand/words/methods/strings.rs +++ b/src/lib/parser/shell_expand/words/methods/strings.rs @@ -5,7 +5,7 @@ use super::{ }, MethodArgs, }; -use parser::assignments::is_array; +use crate::parser::assignments::is_array; use regex::Regex; use small; use std::path::Path; @@ -359,7 +359,7 @@ impl<'a> StringMethod<'a> { #[cfg(test)] mod test { use super::*; - use types; + use crate::types; struct VariableExpander; diff --git a/src/lib/parser/shell_expand/words/mod.rs b/src/lib/parser/shell_expand/words/mod.rs index a3e37fc0bdd8dd54532f1c95dbd1a5513543380a..da6658630ee32ebaf8e2ece93bd700fd678151b5 100644 --- a/src/lib/parser/shell_expand/words/mod.rs +++ b/src/lib/parser/shell_expand/words/mod.rs @@ -4,9 +4,8 @@ mod tests; pub(crate) use self::methods::{ArrayMethod, Pattern, StringMethod}; use super::{expand_string, Expander}; -use lexers::ArgumentSplitter; -pub use ranges::{Select, SelectWithSize}; -use shell::escape::unescape; +pub use crate::ranges::{Select, SelectWithSize}; +use crate::{lexers::ArgumentSplitter, shell::escape::unescape}; use std::borrow::Cow; // Bit Twiddling Guide: diff --git a/src/lib/parser/shell_expand/words/tests.rs b/src/lib/parser/shell_expand/words/tests.rs index d5ffbd21f512022c2ca914bbddfd927f4212f1ec..f79966d814ab9a850379327f240fec9e89aae2dd 100644 --- a/src/lib/parser/shell_expand/words/tests.rs +++ b/src/lib/parser/shell_expand/words/tests.rs @@ -1,6 +1,8 @@ use super::*; -use ranges::{Index, Range}; -use types::{self, Array}; +use crate::{ + ranges::{Index, Range}, + types::{self, Array}, +}; struct Empty; diff --git a/src/lib/parser/statement/case.rs b/src/lib/parser/statement/case.rs index dbbe4b8f94f177336466927e016946f2b7c12974..e0daf2f6c1fe3565c00da073e1118d664b60575f 100644 --- a/src/lib/parser/statement/case.rs +++ b/src/lib/parser/statement/case.rs @@ -1,4 +1,4 @@ -use lexers::ArgumentSplitter; +use crate::lexers::ArgumentSplitter; use std::fmt::{self, Display, Formatter}; #[derive(Debug, PartialEq)] diff --git a/src/lib/parser/statement/functions.rs b/src/lib/parser/statement/functions.rs index cdf3fac8d11e7b3d2bc2d3d3d0a27b817bb905e5..66ecb1277b95d36c6538fbf164976c87d877370f 100644 --- a/src/lib/parser/statement/functions.rs +++ b/src/lib/parser/statement/functions.rs @@ -1,5 +1,5 @@ use super::split_pattern; -use lexers::assignments::{KeyBuf, KeyIterator, TypeError}; +use crate::lexers::assignments::{KeyBuf, KeyIterator, TypeError}; use std::fmt::{self, Display, Formatter}; #[derive(Debug, PartialEq)] @@ -51,8 +51,10 @@ pub(crate) fn collect_arguments(args: KeyIterator) -> Result<Vec<KeyBuf>, Functi #[cfg(test)] mod tests { - use lexers::assignments::{KeyBuf, Primitive}; - use parser::statement::functions::{collect_arguments, parse_function, FunctionParseError}; + use crate::{ + lexers::assignments::{KeyBuf, Primitive}, + parser::statement::functions::{collect_arguments, parse_function, FunctionParseError}, + }; #[test] fn function_parsing() { diff --git a/src/lib/parser/statement/mod.rs b/src/lib/parser/statement/mod.rs index 5113e11a5ad29d8fce448f48843b0acf4199da86..956fb4b9e4fc4826f3f75162187bb8a162dbcbc2 100644 --- a/src/lib/parser/statement/mod.rs +++ b/src/lib/parser/statement/mod.rs @@ -10,7 +10,7 @@ pub(crate) use self::{ parse::parse, splitter::{StatementError, StatementSplitter, StatementVariant}, }; -use shell::flow_control::Statement; +use crate::shell::flow_control::Statement; /// Parses a given statement string and return's the corresponding mapped /// `Statement` diff --git a/src/lib/parser/statement/parse.rs b/src/lib/parser/statement/parse.rs index 59b1fa423179eb1e1017d1950baec24a9017faf9..b6eb46a4eb0ea5036238e1777c49f1ca5e8a5e6c 100644 --- a/src/lib/parser/statement/parse.rs +++ b/src/lib/parser/statement/parse.rs @@ -3,10 +3,12 @@ use super::{ case, functions::{collect_arguments, parse_function}, }; -use lexers::{assignment_lexer, ArgumentSplitter}; -use shell::{ - flow_control::{Case, ElseIf, ExportAction, LocalAction, Statement}, - status::FAILURE, +use crate::{ + lexers::{assignment_lexer, ArgumentSplitter}, + shell::{ + flow_control::{Case, ElseIf, ExportAction, LocalAction, Statement}, + status::FAILURE, + }, }; use small; use std::char; @@ -235,8 +237,10 @@ pub(crate) fn parse(code: &str) -> Statement { mod tests { use self::pipelines::PipeItem; use super::*; - use lexers::assignments::{KeyBuf, Primitive}; - use shell::{flow_control::Statement, Job, JobKind}; + use crate::{ + lexers::assignments::{KeyBuf, Primitive}, + shell::{flow_control::Statement, Job, JobKind}, + }; #[test] fn parsing_for() { diff --git a/src/lib/shell/assignments.rs b/src/lib/shell/assignments.rs index d1972786ae7dea30d31e8431d24e2b9a2d75b87d..6f46bdcfd3eb81c4a82a2934fe64b1a1df13bad3 100644 --- a/src/lib/shell/assignments.rs +++ b/src/lib/shell/assignments.rs @@ -3,11 +3,14 @@ use super::{ status::*, Shell, }; +use crate::{ + lexers::assignments::{Operator, Primitive}, + parser::assignments::*, + shell::{history::ShellHistory, variables::VariableType}, + types, +}; use hashbrown::HashMap; use itoa; -use lexers::assignments::{Operator, Primitive}; -use parser::assignments::*; -use shell::{history::ShellHistory, variables::VariableType}; use std::{ env, ffi::OsStr, @@ -18,7 +21,6 @@ use std::{ result::Result, str, }; -use types; fn list_vars(shell: &Shell) -> Result<(), io::Error> { let stdout = io::stdout(); @@ -58,9 +60,9 @@ fn arithmetic_op(operator: Operator, value: f64) -> Result<Box<dyn Fn(f64) -> f6 /// exporting variables to some global environment pub(crate) trait VariableStore { /// Set a local variable given a binding - fn local(&mut self, LocalAction) -> i32; + fn local(&mut self, action: LocalAction) -> i32; /// Export a variable to the process environment given a binding - fn export(&mut self, ExportAction) -> i32; + fn export(&mut self, action: ExportAction) -> i32; } impl VariableStore for Shell { diff --git a/src/lib/shell/binary/designators.rs b/src/lib/shell/binary/designators.rs index be01ed222e2739a1447f25317a9e2173695da558..aff6ebd5bf237996fe803a3326e0a1883dc9859a 100644 --- a/src/lib/shell/binary/designators.rs +++ b/src/lib/shell/binary/designators.rs @@ -1,5 +1,7 @@ -use lexers::{ArgumentSplitter, DesignatorLexer, DesignatorToken}; -use shell::Shell; +use crate::{ + lexers::{ArgumentSplitter, DesignatorLexer, DesignatorToken}, + shell::Shell, +}; use std::{borrow::Cow, str}; pub(crate) fn expand_designators<'a>(shell: &Shell, cmd: &'a str) -> Cow<'a, str> { diff --git a/src/lib/shell/binary/mod.rs b/src/lib/shell/binary/mod.rs index 41370c47c5179ce9e1069ca264dc07828fc2bf18..23e59e7f8ffe4d15ae0e4f96489c1fa87cee15bf 100644 --- a/src/lib/shell/binary/mod.rs +++ b/src/lib/shell/binary/mod.rs @@ -10,9 +10,9 @@ use self::{ terminate::{terminate_quotes, terminate_script_quotes}, }; use super::{status::*, FlowLogic, Shell, ShellHistory}; +use crate::types; use liner::{Buffer, Context}; use std::{env, iter, path::Path, process}; -use types; pub const MAN_ION: &str = r#"NAME ion - ion shell diff --git a/src/lib/shell/binary/prompt.rs b/src/lib/shell/binary/prompt.rs index f8e1023b286d18c5bfd45b4e1d21f11509d260a5..71b342df7c1a48777d34373576c0ec122c23f1b6 100644 --- a/src/lib/shell/binary/prompt.rs +++ b/src/lib/shell/binary/prompt.rs @@ -1,7 +1,9 @@ -use parser::shell_expand::expand_string; -use shell::{flags::UNTERMINATED, Capture, Function, Shell}; +use crate::{ + parser::shell_expand::expand_string, + shell::{flags::UNTERMINATED, Capture, Function, Shell}, + sys, +}; use std::{io::Read, process}; -use sys; pub(crate) fn prompt(shell: &mut Shell) -> String { let blocks = diff --git a/src/lib/shell/binary/readln.rs b/src/lib/shell/binary/readln.rs index 29f0c24ce3ab9d7299f6d2582b514c0cdd2a1114..c184c6ce2c32bb33ec96852c06e641e25ab6611c 100644 --- a/src/lib/shell/binary/readln.rs +++ b/src/lib/shell/binary/readln.rs @@ -1,8 +1,7 @@ use super::super::{completer::*, Binary, DirectoryStack, Shell, Variables}; +use crate::{sys, types}; use liner::{BasicCompleter, CursorPosition, Event, EventKind}; use std::{env, io::ErrorKind, mem, path::PathBuf}; -use sys; -use types; pub(crate) fn readln(shell: &mut Shell) -> Option<String> { { diff --git a/src/lib/shell/binary/terminate.rs b/src/lib/shell/binary/terminate.rs index 6e5272538c9ccd5b9a0469cbd388ec3cffca8493..bc295ad4b88f26bb452ff3c32be19babe71b75a2 100644 --- a/src/lib/shell/binary/terminate.rs +++ b/src/lib/shell/binary/terminate.rs @@ -1,5 +1,7 @@ -use parser::Terminator; -use shell::{flags::UNTERMINATED, status::*, Binary, FlowLogic, Shell}; +use crate::{ + parser::Terminator, + shell::{flags::UNTERMINATED, status::*, Binary, FlowLogic, Shell}, +}; pub(crate) fn terminate_script_quotes<I: Iterator<Item = String>>( shell: &mut Shell, diff --git a/src/lib/shell/directory_stack.rs b/src/lib/shell/directory_stack.rs index e64ae506eac21cebeb204b3db1d9966ff4296f44..e74e4eb8480fdff672b66d41820085be68844622 100644 --- a/src/lib/shell/directory_stack.rs +++ b/src/lib/shell/directory_stack.rs @@ -2,13 +2,13 @@ use super::{ status::{FAILURE, SUCCESS}, variables::Variables, }; +use crate::sys::env as sys_env; use std::{ borrow::Cow, collections::VecDeque, env::{self, set_current_dir}, path::{Component, Path, PathBuf}, }; -use sys::env as sys_env; fn set_current_dir_ion(dir: &Path) -> Result<(), Cow<'static, str>> { set_current_dir(dir).map_err(|why| Cow::Owned(format!("{}", why)))?; diff --git a/src/lib/shell/flow.rs b/src/lib/shell/flow.rs index b9d0c4de35d1f4feaa82f6db52b2291bc640b920..d1df5fdcf786025acf667a3410f26fd4bbe06352 100644 --- a/src/lib/shell/flow.rs +++ b/src/lib/shell/flow.rs @@ -5,17 +5,19 @@ use super::{ status::*, Shell, }; -use itertools::Itertools; -use parser::{ - assignments::is_array, - expand_string, parse_and_validate, - pipelines::{PipeItem, Pipeline}, - ForValueExpression, StatementSplitter, +use crate::{ + parser::{ + assignments::is_array, + expand_string, parse_and_validate, + pipelines::{PipeItem, Pipeline}, + ForValueExpression, StatementSplitter, + }, + shell::{assignments::VariableStore, variables::VariableType}, + types, }; -use shell::{assignments::VariableStore, variables::VariableType}; +use itertools::Itertools; use small; use std::io::{stdout, Write}; -use types; macro_rules! handle_signal { ($signal:expr) => { diff --git a/src/lib/shell/flow_control.rs b/src/lib/shell/flow_control.rs index e114555c65f85f65f15f400036ef987c3ce805d5..21548ca10fe1fc355239c962a622ec40c232ceec 100644 --- a/src/lib/shell/flow_control.rs +++ b/src/lib/shell/flow_control.rs @@ -1,10 +1,12 @@ -use lexers::assignments::{KeyBuf, Operator, Primitive}; -use parser::{assignments::*, pipelines::Pipeline}; -use shell::{flow::FlowLogic, Shell}; +use crate::{ + lexers::assignments::{KeyBuf, Operator, Primitive}, + parser::{assignments::*, pipelines::Pipeline}, + shell::{flow::FlowLogic, Shell}, + types, +}; use small; use smallvec::SmallVec; use std::fmt::{self, Display, Formatter}; -use types; #[derive(Debug, PartialEq, Clone)] pub(crate) struct ElseIf { diff --git a/src/lib/shell/fork.rs b/src/lib/shell/fork.rs index 82670a33085537c65d58157b327d1f9aaa53de01..abc39ca2c96f5ef336c445c938d94b4c2416de25 100644 --- a/src/lib/shell/fork.rs +++ b/src/lib/shell/fork.rs @@ -1,10 +1,10 @@ use super::{IonError, Shell}; +use crate::sys; use std::{ fs::File, io, os::unix::io::{AsRawFd, FromRawFd}, }; -use sys; pub fn wait_for_child(pid: u32) -> io::Result<u8> { let mut status; diff --git a/src/lib/shell/fork_function.rs b/src/lib/shell/fork_function.rs index 4b6b6d50a5440e93c98cc61d419edd7d10428f9c..cac2488b75e52ae8debcac2a87cf47b40544eee9 100644 --- a/src/lib/shell/fork_function.rs +++ b/src/lib/shell/fork_function.rs @@ -1,6 +1,8 @@ -use shell::{Capture, Function, Shell}; +use crate::{ + shell::{Capture, Function, Shell}, + sys, +}; use std::process; -use sys; pub(crate) fn command_not_found(shell: &mut Shell, command: &str) -> bool { fork_function(shell, "COMMAND_NOT_FOUND", &["ion", command]) diff --git a/src/lib/shell/history.rs b/src/lib/shell/history.rs index 7f39d003f70c86fff2156d7e9edd2f12ce7f8dff..47423e1d2c29471497845ae0d9dd44885b8953db 100644 --- a/src/lib/shell/history.rs +++ b/src/lib/shell/history.rs @@ -1,12 +1,12 @@ -use shell::{status::*, Shell}; +use crate::shell::{status::*, Shell}; +use crate::types; use regex::Regex; use small; use std::{ io::{self, Write}, time::{SystemTime, UNIX_EPOCH}, }; -use types; bitflags! { struct IgnoreFlags: u8 { diff --git a/src/lib/shell/job.rs b/src/lib/shell/job.rs index 7ba29f7bb3a656a15d64e76742d35188259a7a88..5a27a64ed36ec60970f1a6aad636f7927324e7d9 100644 --- a/src/lib/shell/job.rs +++ b/src/lib/shell/job.rs @@ -1,9 +1,11 @@ use super::Shell; -use builtins::{BuiltinFunction, BUILTINS}; -use parser::{expand_string, pipelines::RedirectFrom}; -use shell::pipe_exec::PipelineExecution; +use crate::{ + builtins::{BuiltinFunction, BUILTINS}, + parser::{expand_string, pipelines::RedirectFrom}, + shell::pipe_exec::PipelineExecution, + types::{self, Array}, +}; use std::{fmt, fs::File, str}; -use types::{self, Array}; #[derive(Debug, PartialEq, Clone, Copy)] pub(crate) enum JobKind { diff --git a/src/lib/shell/mod.rs b/src/lib/shell/mod.rs index 0f9a36dbbb7033a7af2301ad9f169d88c8b67a96..673cbf070e063c3d07ccdba3f291315abb8345fd 100644 --- a/src/lib/shell/mod.rs +++ b/src/lib/shell/mod.rs @@ -49,9 +49,13 @@ use self::{ status::*, variables::{GetVariable, VariableType, Variables}, }; -use builtins::{BuiltinMap, BUILTINS}; +use crate::{ + builtins::{BuiltinMap, BUILTINS}, + parser::{pipelines::Pipeline, Expander, MapKeyIter, MapValueIter, Select, Terminator}, + sys, + types::{self, Array}, +}; use liner::Context; -use parser::{pipelines::Pipeline, Expander, MapKeyIter, MapValueIter, Select, Terminator}; use std::{ fs::File, io::{self, Read, Write}, @@ -62,8 +66,6 @@ use std::{ sync::{atomic::Ordering, Arc, Mutex}, time::SystemTime, }; -use sys; -use types::{self, Array}; use xdg::BaseDirectories; #[derive(Debug, Fail)] @@ -437,7 +439,7 @@ impl<'a> Expander for Shell { /// Expand a string variable given if its quoted / unquoted fn string(&self, name: &str, quoted: bool) -> Option<types::Str> { - use ascii_helpers::AsciiReplace; + use crate::ascii_helpers::AsciiReplace; if name == "?" { Some(types::Str::from(self.previous_status.to_string())) } else if quoted { @@ -502,7 +504,7 @@ impl<'a> Expander for Shell { )]); } Select::Index(index) => { - use ranges::Index; + use crate::ranges::Index; return Some(array![format!( "{}", hmap.get(&types::Str::from( @@ -545,7 +547,7 @@ impl<'a> Expander for Shell { )]); } Select::Index(index) => { - use ranges::Index; + use crate::ranges::Index; return Some(array![format!( "{}", bmap.get(&types::Str::from( diff --git a/src/lib/shell/pipe_exec/fork.rs b/src/lib/shell/pipe_exec/fork.rs index b91970ea5024276d8c5d74028b59d77fe83e0fa2..8d6569e5e7eba8828ae135ddfb7f6a65ccb7bee3 100644 --- a/src/lib/shell/pipe_exec/fork.rs +++ b/src/lib/shell/pipe_exec/fork.rs @@ -1,5 +1,5 @@ +use crate::sys; use smallvec::SmallVec; -use sys; /// Ensures that the forked child is given a unique process ID. pub(crate) fn create_process_group(pgid: u32) { let _ = sys::setpgid(0, pgid); } diff --git a/src/lib/shell/pipe_exec/job_control.rs b/src/lib/shell/pipe_exec/job_control.rs index 016d9cca445ee2589f3fec583298d6b44a3fd174..5bd4e2bd5488e12abfc5e6f1c5ba0c62a3a13b65 100644 --- a/src/lib/shell/pipe_exec/job_control.rs +++ b/src/lib/shell/pipe_exec/job_control.rs @@ -2,13 +2,13 @@ use super::{ super::{signals, status::*, Shell}, foreground::{BackgroundResult, ForegroundSignals}, }; +use crate::sys; use std::{ fmt, process, sync::{Arc, Mutex}, thread::{sleep, spawn}, time::Duration, }; -use sys; /// When given a process ID, that process's group will be assigned as the /// foreground process group. @@ -250,7 +250,7 @@ impl JobControl for Shell { } } -use sys::{ +use crate::sys::{ kill, strerror, waitpid, wcoredump, wexitstatus, wifcontinued, wifexited, wifsignaled, wifstopped, wstopsig, wtermsig, ECHILD, SIGINT, SIGPIPE, WCONTINUED, WNOHANG, WUNTRACED, }; diff --git a/src/lib/shell/pipe_exec/mod.rs b/src/lib/shell/pipe_exec/mod.rs index 8f4a71032001baa9ebf682c22e2c535d87bd0a9d..972d756684ac161334139a708fe6ba5091858a43 100644 --- a/src/lib/shell/pipe_exec/mod.rs +++ b/src/lib/shell/pipe_exec/mod.rs @@ -26,8 +26,11 @@ use super::{ status::*, JobKind, Shell, }; -use builtins::{self, BuiltinFunction}; -use parser::pipelines::{Input, PipeItem, Pipeline, RedirectFrom, Redirection}; +use crate::{ + builtins::{self, BuiltinFunction}, + parser::pipelines::{Input, PipeItem, Pipeline, RedirectFrom, Redirection}, + sys, +}; use small; use smallvec::SmallVec; use std::{ @@ -38,7 +41,6 @@ use std::{ path::Path, process::{self, exit}, }; -use sys; type RefinedItem = (RefinedJob, JobKind, Vec<Redirection>, Vec<Input>); diff --git a/src/lib/shell/pipe_exec/pipes.rs b/src/lib/shell/pipe_exec/pipes.rs index fecc3a8f1e8733297f0e9b5811118d825f730614..9fc165524aff07ddb8725d2a1d01d555a4d439d5 100644 --- a/src/lib/shell/pipe_exec/pipes.rs +++ b/src/lib/shell/pipe_exec/pipes.rs @@ -3,8 +3,8 @@ use super::{ append_external_stdio_pipe, pipe_fail, }; +use crate::sys; use std::{fs::File, os::unix::io::FromRawFd}; -use sys; pub(crate) struct TeePipe<'a> { parent: &'a mut RefinedJob, diff --git a/src/lib/shell/pipe_exec/streams.rs b/src/lib/shell/pipe_exec/streams.rs index 43a167955e7445d067945cd3bd35d0abe941dd39..9b5e6b8f9247368fe0bf5d75ff8afce82a21f51b 100644 --- a/src/lib/shell/pipe_exec/streams.rs +++ b/src/lib/shell/pipe_exec/streams.rs @@ -1,9 +1,9 @@ +use crate::sys; use std::{ fs::File, io, os::unix::io::{AsRawFd, FromRawFd, RawFd}, }; -use sys; /// Use dup2 to replace `old` with `new` using `old`s file descriptor ID pub(crate) fn redir(old: RawFd, new: RawFd) { diff --git a/src/lib/shell/signals.rs b/src/lib/shell/signals.rs index c5a44ac0378c43f723a23732e10dbd7dbdd4406b..76fde144b511b875106bc1cac298898ea9b2192e 100644 --- a/src/lib/shell/signals.rs +++ b/src/lib/shell/signals.rs @@ -6,9 +6,9 @@ // use std::sync::atomic::{ATOMIC_U8_INIT, AtomicU8}; use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT}; -use sys; +use crate::sys; -pub(crate) use sys::signals::{block, unblock}; +pub(crate) use crate::sys::signals::{block, unblock}; pub static PENDING: AtomicUsize = ATOMIC_USIZE_INIT; pub const SIGINT: u8 = 1; diff --git a/src/lib/shell/variables/mod.rs b/src/lib/shell/variables/mod.rs index 2f3a2a858203d8b87e73c76c8905e554e4a9a302..6690185c0ab3e93e4e0ee9d261e41d6dab7e55d4 100644 --- a/src/lib/shell/variables/mod.rs +++ b/src/lib/shell/variables/mod.rs @@ -4,6 +4,10 @@ use super::{ flow_control::Function, status::{FAILURE, SUCCESS}, }; +use crate::{ + sys::{self, env as sys_env, geteuid, getpid, getuid, variables as self_sys}, + types::{self, Array}, +}; use hashbrown::HashMap; use liner::Context; use std::{ @@ -12,8 +16,6 @@ use std::{ mem, ops::{Deref, DerefMut}, }; -use sys::{self, env as sys_env, geteuid, getpid, getuid, variables as self_sys}; -use types::{self, Array}; use unicode_segmentation::UnicodeSegmentation; use xdg::BaseDirectories; @@ -625,7 +627,7 @@ pub trait GetVariable<T> { impl GetVariable<types::Str> for Variables { fn get(&self, name: &str) -> Option<types::Str> { - use types::Str; + use crate::types::Str; match name { "MWD" => return Some(Str::from(VariableType::Str(self.get_minimal_directory()))), @@ -689,7 +691,7 @@ get_var!(Function, Function(func) => func); #[cfg(test)] mod tests { use super::*; - use parser::{expand_string, Expander}; + use crate::parser::{expand_string, Expander}; struct VariableExpander(pub Variables); diff --git a/src/lib/types.rs b/src/lib/types.rs index 09eb72293e7ea09264ca3369908fe7c88a31e35e..97db4339c867f14028c4115c8546e3dd89d25790 100644 --- a/src/lib/types.rs +++ b/src/lib/types.rs @@ -1,5 +1,5 @@ +use crate::shell::variables::VariableType; use hashbrown::HashMap as HashbrownMap; -use shell::variables::VariableType; use small; use smallvec::SmallVec; use std::{