Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/bashkit/docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ for sandbox security reasons. See the compliance spec for details.
| `eval` | `command...` | POSIX construct and execute command |
| `readonly` | `VAR[=value]`, `-p` | POSIX mark variable read-only |
| `times` | - | POSIX display process times |
| `grep` | `-i`, `-v`, `-c`, `-n`, `-E`, `-q` | Pattern matching |
| `grep` | `-G/-E/-F/-P`, `-e`, `-f`, `-i/-y`, `--no-ignore-case`, `-v`, `-w`, `-x`, `-c`, `-l`, `-L`, `-o`, `-q`, `-s`, `-m`, `-n`, `-b`, `-H/-h`, `--label`, `-T`, `-Z`, `-z`, `-a`, `-I`, `--binary-files`, `-A/-B/-C/-NUM`, `--group-separator`, `--no-group-separator`, `-r/-R`, `-d`, `-D`, `--include/--exclude/--exclude-from/--exclude-dir`; long-option prefixes | GNU grep 3.11 output; BRE/ERE leftmost-longest, back-references |
| `rg` | `-i/-S/-s`, `-n/-N`, `--column`, `-b/--byte-offset`, `--vimgrep`, basic `--json`, `--stats`, `--null`, `-c`, `--count-matches`, `--include-zero`, `-l`, `--files-with-matches`, `--files-without-match`, `--files`, `-F`, `-w`, `-x`, `-a/--text`, `--binary`, `-m`, `-M/--max-columns`, `--max-columns-preview`, `--max-depth`, `-A`, `-B`, `-C`, separator flags, `--heading/--no-heading`, `--sort/--sortr`, `--path-separator`, `-g/--glob`, `--ignore-file`, `.ignore`/`.gitignore`, `--no-ignore*`, `--require-git/--no-require-git`, `-u/--unrestricted`, `--messages/--no-messages`, `-t/--type`, `-T/--type-not`, `--type-add`, `--type-clear`, `--type-list`, `--hidden/--no-hidden`, `-o`, `-q`, `-e`, `-f`, `-E/--encoding` (`auto`, `none`, UTF-8, UTF-16LE/BE), `-r`, `--passthru`, `--trim`, `-H/-I`, `--no-config`, `--line-buffered`, `--block-buffered`, `--mmap/--no-mmap`, `-P/--pcre2`, `--no-pcre2`, `--engine`, `--auto-hybrid-regex`, `--no-auto-hybrid-regex`, `--help`, `--version` | Recursive ripgrep-style search |
| `sed` | `s///[gpiImMN w]`, `y`, `d`, `D`, `p`, `P`, `n`, `N`, `q[N]`, `Q[N]`, `=`, `l[N]`, `z`, `F`, `a`, `i`, `c`, `r`, `R`, `w`, `W`, `h/H/g/G/x`, `b`/`t`/`T`/`:label`, `{}`, `#`/`#n`; addresses `N`, `$`, `/re/[IM]`, `\cREc`, `first~step`, `a,b`, `a,+N`, `a,~N`, `0,/re/`, `!`; options `-n -e -f -i[SUF] -E/-r -s -z -l N -u --` and long forms | Stream editing; one stream across operands unless `-s`/`-i` |
| `awk` (also `gawk`, `mawk`, `nawk`) | `'{print}'`, `-F`, `-v`, loops, arrays, increment, ternary | Text processing |
Expand Down
2 changes: 1 addition & 1 deletion crates/bashkit/src/builtins/awk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mod io;
mod lexer;
mod order;
mod parser;
mod regex;
pub(crate) mod regex;
mod value;

use std::future::Future;
Expand Down
12 changes: 11 additions & 1 deletion crates/bashkit/src/builtins/awk/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,22 @@ impl AwkRegex {
let mut pat = String::with_capacity(t.pattern.len() + 8);
pat.push_str(if icase { "(?si)" } else { "(?s)" });
pat.push_str(&t.pattern);
Self::from_translated(pat, t.needs_longest)
}

/// Build from a pattern already in `regex` crate syntax (flags
/// included). Other POSIX dialects (grep's BRE/ERE) translate with
/// their own rules and reuse the leftmost-longest machinery here.
pub(crate) fn from_translated(
pat: String,
needs_longest: bool,
) -> Result<AwkRegex, RegexError> {
let re = regex::RegexBuilder::new(&pat)
.size_limit(REGEX_SIZE_LIMIT)
.dfa_size_limit(REGEX_DFA_SIZE_LIMIT)
.build()
.map_err(|e| RegexError(short_error(&e)))?;
let longest = if t.needs_longest {
let longest = if needs_longest {
DFA::builder()
.configure(
DFA::config()
Expand Down
Loading
Loading