1 stable release
Uses new Rust 2024
| 1.0.2 | Oct 22, 2025 |
|---|
#3 in #disable
5KB
88 lines
echo-oxide
A small, from-scratch Rust implementation of the Unix echo command.
echo-oxide aims to be a lightweight, correct, and well-tested reimplementation of the standard echo utility.
It mimics the common behaviors found in POSIX shells and GNU coreutils variants, while being implemented and distributed in Rust for clarity, safety, and portability.
- Language: Rust
- Goal: Provide a simple CLI that prints its arguments with configurable escaping and newline behavior.
Features
- Print positional arguments separated by spaces.
- Default trailing newline after output.
- Common flags:
-n— do not print the trailing newline.-e— enable interpretation of backslash escapes (e.g.\n,\t,\\).-E— disable interpretation of backslash escapes (default behavior on many systems).
- Compatible behavior with typical echo semantics (see Notes / Compatibility).
- Minimal external dependencies.
Badges
TODO
Table of contents
Installation Usage Flags / Behavior Examples Testing Development (building, linting, formatting) Contributing License Acknowledgements
Installation
-
From source (requires Rust toolchain):
- Clone the repo:
git clone https://github.com/reactive-firewall/echo-oxide.git cd echo-oxide - Build in release mode:
cargo build --release - Optionally install the binary:
cargo install --path .
- Clone the repo:
-
From crates.io (if published):
cargo install echo-oxide
Usage Run the built binary directly or via cargo:
Using source-build installed binary: echo [OPTIONS] [ARG...]
Using crate.io installed binary: echo-oxide [OPTIONS] [ARG...]
With cargo run (development): cargo run -- [OPTIONS] [ARG...]
Basic behavior:
- Print all provided arguments separated by a single space. By default, print a newline after the output unless suppressed with
-n.
Flags / Behavior
-
-nDo not print the trailing newline. -
-eEnable interpretation of backslash escapes. Supported sequences typically include:\\— backslash\a— alert (BEL)\b— backspace\c— produce no further output\f— form feed\n— newline\r— carriage return\t— horizontal tab\v— vertical tab\0NNN— byte with octal value NNN (up to three digits)\xHH— byte with hexadecimal value HH
-
-EExplicitly disable interpretation of escape sequences (default for many shells).
Notes / Compatibility
echosemantics differ across shells and platforms (bash builtin vs. /bin/echo vs. GNU echo).echo-oxide tries to follow commonly expected behavior (drop-in for most BSD variants); including how\cis implemented, (e.g. output stops immediately and no trailing newline is printed).- Unicode handling: strings are treated as UTF-8; escape sequences that produce bytes should be considered in terms of UTF-8 validity.
Examples
Basic: echo-oxide Hello world Output: Hello world (with trailing newline)
No newline: echo-oxide -n Hello Output: Hello (no newline)
Escapes: echo-oxide -e "Line1\nLine2" Output:
Line1
Line2
Literal backslash: echo-oxide -e "A backslash: \\" Output: A backslash: \
Stop output with \c: echo-oxide -e "Start\cShouldNotAppear" Output: Start
Testing
- Run unit and integration tests:
cargo test
Development
-
Build:
cargo build cargo build --release -
Run:
cargo run -- [ARGS...]
Contributing
Contributions are welcome. Suggested workflow:
- Fork the repository.
- Create a branch for your feature/fix:
git checkout -b feature-my-stuff - Implement changes with tests.
- Run
cargo test. - Submit a pull request with a clear description and tests.
Please include tests for any new behavior and update the README where applicable.
Reporting issues
Open a GitHub Issue in this repository with a clear title, description, steps to reproduce, and expected vs actual behavior. Tag any relevant platform / shell information to help reproduce differences.
License
Your choice of: Apache-2.0 or MIT-NFA
Acknowledgements
- Inspired by the standard FreeBSD
echoutility.
Dependencies
~1–1.5MB
~27K SLoC