4 releases (breaking)

new 0.4.0 Sep 28, 2024
0.3.0 Jul 12, 2024
0.2.0 Jun 9, 2024
0.1.0 Apr 13, 2024

#2856 in Command line utilities


Used in yash-cli

GPL-3.0-or-later

3MB
61K SLoC

Yash-builtin

yash-builtin is a Rust library crate that implements the built-in utilities of yash.

yash-builtin at crates.io yash-builtin at docs.rs Build status

License

This crate is distributed under GPLv3.


lib.rs:

Implementation of the shell built-in utilities.

Each built-in utility is implemented in the submodule named after the utility. The submodule contains the main function that implements the built-in utility. The submodule many also export other items that are used by the main function. The module documentation for each submodule describes the specification of the built-in utility.

The common module provides common functions that are used for implementing built-in utilities.

Stack

Many built-ins in this crate use Stack::current_builtin to obtain the command word that invoked the built-in. It is used to report the command location in error messages, switch the behavior of the built-in depending on the command, etc. For the built-ins to work correctly, the stack should contain a built-in frame so that Stack::current_builtin provides the correct command word.

Optional dependencies

The yash-builtin crate has an optional dependency on the yash-semantics crate, which is enabled by default. If you disable the yash-semantics feature, the following built-ins will be unavailable:

  • command
  • eval
  • exec
  • read
  • source
  • type
  • wait

The yash-builtin crate also has an optional dependency on the yash-prompt crate, which is enabled by default. If you disable the yash-prompt feature, the read built-in will not print the prompt. Note that the yash-prompt feature requires the yash-semantics feature.

Dependencies

~9–19MB
~280K SLoC