Skip to content

Add support for Yash (Yet another shell) #7121

@suprstarrd

Description

@suprstarrd

Code of Conduct

  • I agree to follow this project's Code of Conduct

What would you like to see added?

Requesting support for Yash (acronym for "Yet another shell") - website here. This is a shell I regularly use.

From their project README:

Yash, yet another shell, is a POSIX-compliant command line shell
written in C99 (ISO/IEC 9899:1999). Yash is intended to be the most
POSIX-compliant shell in the world while supporting features for daily
interactive and scripting use. Notable features are:

  • Global aliases
  • Arrays
  • Socket redirection, pipeline redirection, and process redirection
  • Brace expansion and extended globbing
  • Fractional numbers in arithmetic expansion
  • Prompt command and command-not-found handler
  • Command line completion with predefined completion scripts for more
    than 100 commands
  • Command line prediction based on command history

This could also be used to rework the Bash implementation for further compatibility with even more shells.

Something I have independently discovered is that files ending in .sh are automatically placed in a "POSIXly-correct" mode which removes some of these additional Yash features. (As an aside, that functionality could be helpful if you want to implement support for Bash's POSIX mode too. See Bash's POSIX mode limitations.)

Remainder of the Yash README (with things like implementation details and other limitations)

Yash now fully supports POSIX.1-2024 (IEEE Std 1003.1)
except for the limitations listed below.

Yash is stable. A maintenance update is released every three months or
so.

  • In C, a null character represents the end of a string. If input to
    the shell itself contains a null character, characters following
    the null character will be ignored.
  • The GCC extension keyword __attribute__ is used in the source
    code. When not compiled with GCC or Clang, this keyword is removed
    by the preprocessor, so generally there is no harm. But if your
    compiler uses this keyword for any other purpose, compilation may
    fail. Additionally, some other identifiers starting with _ may
    cause compilation errors on some rare environments.
  • Some signals are assumed to have the specific numbers:
    SIGHUP=1 SIGINT=2 SIGQUIT=3 SIGABRT=6
    SIGKILL=9 SIGALRM=14 SIGTERM=15
  • POSIX disallows non-interactive shells to ignore or catch SIGTTIN,
    SIGTTOU, and SIGTSTP by default. Yash, however, ignores these
    signals if job-control is enabled, even if non-interactive.
  • File permission flags are assumed to have the specific values:
    0400=user read    0200=user write   0100=user execute
    0040=group read   0020=group write  0010=group execute
    0004=other read   0002=other write  0001=other execute
    
  • The character categorization in locales other than the POSIX locale
    is assumed upward compatible with the POSIX locale.
  • The -o nolog option is not supported: it is silently ignored.
  • According to POSIX, the command printf %c foo should print the
    first byte of string foo. Yash prints the first character of
    foo, which may be more than one byte.
  • The return built-in, if executed in a trap, can operate only on a
    function, script, or loop that has been executed within the trap.
    This limitation is not strictly POSIX-compliant, but needed for
    consistent and predictable behavior of the shell.
  • Results of pathname expansion is sorted only by collating sequence
    of the current locale. If the collating sequence does not have a
    total ordering of characters, order of uncomparable results are
    unstable. This limitation is not strictly POSIX-compliant, but
    inevitable due to use of wide characters in the whole shell.
  • Most part of the shell cannot handle bytes that do not represent
    valid characters, because string operations are written in terms of
    wide character strings. This design choice was made before POSIX
    added requirements for the shell to accept arbitrary bytes in some
    operations, and it is too late to fully implement them.
  • The shell needs the setrlimit function to implement the behavior
    of propagating the wait status of a signaled child process to the
    parent process. This behavior is disabled if the setrlimit
    function is not available, in which case the shell will not be fully
    POSIX-compliant.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions