diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-11-09 17:31:32 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-11-09 17:31:32 +0200 |
commit | a2c5d3328350bda4d8f99220bb51925e490e5a07 (patch) | |
tree | 1401c7056f4b97e94f9853dc0b150bea5bfeb1e9 | |
parent | Properly run commands on ExitSuccess/ExitFailure (diff) | |
download | rshell-a2c5d3328350bda4d8f99220bb51925e490e5a07.tar.xz |
Update manpage
-rw-r--r-- | Makefile | 33 | ||||
-rw-r--r-- | README.md | 25 | ||||
-rw-r--r-- | man/rs.1.scd | 4 | ||||
-rw-r--r-- | src/parser/command.rs | 14 |
4 files changed, 50 insertions, 26 deletions
@@ -6,21 +6,26 @@ CARGO ?= cargo SCDOC ?= scdoc RM ?= rm +man_targets = man/rs.1 + +.PHONY: default default: @${CARGO} build -release: + +man/rs.%: + @${SCDOC} < $@.scd > $@ + +target/release/rs: + @echo Building default target @${CARGO} build --release --locked --all-features --target-dir=target -manpage: - @${SCDOC} < man/rs.1.scd > man/rs.1 -install: release manpage - install -Dm 755 -t "${BIN_DEST}" target/release/rs - install -Dm 555 -t "${MAN_DEST}" man/rs.1 - -run: - @${CARGO} run -fmt: - @${CARGO} fmt -clean: - @${RM} man/rs.1 - @${CARGO} clean + +target/%/release/rs: + @echo Building target $* + @${CARGO} build --target $* --release --locked --all-features --target-dir=target + +musl: target/x86_64-unknown-linux-musl/release/rs + strip target/x86_64-unknown-linux-musl/release/rs + @${CARGO} run --target x86_64-unknown-linux-musl --release +test-musl: + @${CARGO} test --target x86_64-unknown-linux-musl --release --locked --all-features --target-dir=target @@ -10,12 +10,27 @@ It's a shell written in Rust. ### Sounds dumb, how do I use it? -You build it yourself. Clone the repository, and run - cargo build +Building with the default toolchain and target is simple: +```sh +cargo build +``` -To build the manpages you need scdoc: - scdoc < man/rs.1.scd > rs.1 - scdoc < man/rs.5.scd > rs.5 +You can also use musl instead of glibc. If this is not your default toolchain, +you can use rustup to install that target: +```sh +rustup target add x86_64-unknown-linux-musl +cargo build --target x86_64-unknown-linux-musl +``` + +Release builds look like: +```sh +cargo build --release --locked --all-features --target-dir=target +``` +where: + - --release tells cargo to compile a release build + - --locked tells cargo to adhere the Cargo.lock file and prevent it from updating dependencies which is important for reproducible builds. + - --all-features tells cargo to compile with all features of the package enabled. Alternatively, use --features FEATURE1,FEATURE2 if you want enable only selected features. + - --target-dir=target tells cargo to put the target directory in the current directory. ### It doesn't work, what now? diff --git a/man/rs.1.scd b/man/rs.1.scd index 2036f7a..c9c423e 100644 --- a/man/rs.1.scd +++ b/man/rs.1.scd @@ -14,9 +14,9 @@ This is yet another shell | ; : Run command regardless of the previous command's exit status. | || -:[ Run command if the previous command has failed. (todo) +:[ Run command if the previous command has failed. | && -:[ Run command if the previous command has succeeded. (todo) +:[ Run command if the previous command has succeeded. ## Builtins |[ diff --git a/src/parser/command.rs b/src/parser/command.rs index 540dc29..4dea8a6 100644 --- a/src/parser/command.rs +++ b/src/parser/command.rs @@ -7,7 +7,7 @@ use std::process::{Command, ExitStatus}; // | pipe #[derive(Debug)] -pub(in crate::parser) enum Redirect { +enum Redirect { Std, FileOverwrite(String), FileAppend(String), @@ -35,15 +35,15 @@ impl RunOn { } } -pub enum RunResult { +pub(in crate::parser) enum RunResult { Command(ExitStatus), Builtin, } #[derive(Debug)] pub struct CommandInfo { - pub(in crate::parser) args: Vec<String>, - pub(in crate::parser) stdout: Redirect, + args: Vec<String>, + stdout: Redirect, pub(in crate::parser) when: RunOn, } @@ -53,7 +53,11 @@ impl CommandInfo { CommandInfo { args, stdout, when } } - pub fn run(&self, home: &PathBuf, status: &Option<ExitStatus>) -> Result<RunResult, Error> { + pub(in crate::parser) fn run( + &self, + home: &PathBuf, + status: &Option<ExitStatus>, + ) -> Result<RunResult, Error> { match self.args[0].as_str() { "!" => { println!("{:?}", status); |