diff --git a/doc/base.html b/doc/base.html index a41e1239..fb06cf16 100644 --- a/doc/base.html +++ b/doc/base.html @@ -62,6 +62,17 @@ border: 1px solid black; } + #bash-table td, #bash-table th { + overflow: hidden; + border: 1px solid black; + padding: 1em; + } + + #bash-table { + border-collapse: collapse; + border: 1px solid black; + } + nav { flex-basis: 18rem; @@ -96,7 +107,7 @@ } #content-div { - width: 45em; + margin-bottom: 10em; } @@ -104,6 +115,10 @@ font-size: 1.2em; } + p { + width: 45em; + } + .nav-ul { list-style-type: none; margin: 0; @@ -210,6 +225,7 @@

mshell

Examples
  • diff --git a/doc/examples.inc.html b/doc/examples.inc.html index 72ece6ab..1a209c1e 100644 --- a/doc/examples.inc.html +++ b/doc/examples.inc.html @@ -285,3 +285,110 @@

    Versus Awk

    + +

    Versus Bash

    + +

    +Where bash relies on an expansion phase, mshell keeps data on the stack and uses explicit operators. +The snippets below show how to approach familiar shell tasks. +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Topic bash mshell Notes
    Brace expansion +
    touch backup_{1..3}.tar.gz
    +
    +
    3 seq (
    +    idx!
    +    [ 'touch' $"backup_{@idx 1 + str}.tar.gz" ] ;
    +) each
    +
    Generate filenames explicitly, then run the command for each item.
    Tilde expansion +
    grep -R "TODO" ~/projects
    +
    +
    [ 'grep' '-R' 'TODO' ~/projects ] ;
    +
    Tokens that begin with ~/ resolve to the user's home directory.
    Parameter expansion +
    ls "${LOG_DIR:-/var/log}"
    +
    +
    $LOG_DIR? ( $LOG_DIR ) ( '/var/log' ) iff logDir!
    +[ 'ls' ] @logDir append ;
    +
    Use iff (if/else) to choose defaults while keeping values on the stack.
    Command substitution +
    files=$(find src -type f -name '*.msh')
    +printf '%s\n' "$files"
    +
    +
    [ 'find' 'src' '-type' 'f' '-name' '*.msh' ] * > ; lines files!
    +@files len count!
    +$"Found {@count} source files" wl
    +
    * > keeps stdout as a string; lines turns it into a list for further work.
    Arithmetic expansion +
    truncate -s $((512 * 1024)) disk.img
    +
    +
    512 1024 * size!
    +@size str sizeStr!
    +[ 'truncate' '-s' @sizeStr 'disk.img' ] ;
    +
    Apply numeric operators directly, then convert to strings when composing arguments.
    Process substitution +
    diff <(sort errors.log) <(sort errors.log.prev)
    +
    +
    [ 'sort' 'errors.log' ] * > ; psub left!
    +[ 'sort' 'errors.log.prev' ] * > ; psub right!
    +[ 'diff' ] @left append @right append ;
    +
    psub writes captured output to a temporary file and returns the path.
    Redirections +
    printf 'status\n' > /tmp/report.txt
    +grep status < /tmp/report.txt
    +
    +
    [ 'printf' 'status\n' ] `/tmp/report.txt` > ;
    +[ 'grep' 'status' ] `/tmp/report.txt` < * > ; lines matches!
    +@matches len total!
    +$"Matched {@total} lines" wl
    +
    Use path literals with >/<; combine with * > and lines when you want to reuse the output.