Merge nucleic/sleek-thistle-egret-fyej into dev

This commit is contained in:
2026-07-18 05:19:31 -07:00
commit b6be87b72d
677 changed files with 102939 additions and 0 deletions
@@ -0,0 +1,333 @@
name: "Filename expansion"
cases:
- name: "Single file expansion"
stdin: "echo file1.txt"
- name: "Expansion with noglob"
test_files:
- path: "file1.txt"
- path: "file2.txt"
stdin: |
set -f
echo "*.txt:" *.txt
- name: "Multiple file expansion"
test_files:
- path: "file1.txt"
- path: "file2.txt"
stdin: |
echo *.txt
echo *."txt"
- name: "File expansion with nocaseglob"
test_files:
- path: "FILE1.TXT"
- path: "file2.txt"
stdin: |
shopt -s nocaseglob
echo "*.txt:" *.txt
echo "*.TXT:" *.txt
- name: "Nested directory expansion"
test_files:
- path: "dir/file1.txt"
stdin: "echo dir/*"
- name: "Multiple level directory expansion"
test_files:
- path: "dir/subdir/file1.txt"
stdin: "echo dir/subdir/*.txt"
- name: "Expansion with no matches"
test_files:
- path: "file1.txt"
stdin: "echo *.jpg"
- name: "Expansion with no matches + nullglob"
test_files:
- path: "file1.txt"
stdin: |
shopt -s nullglob
echo "*.jpg:" *.jpg
- name: "Expansion with special characters"
test_files:
- path: "file1.txt"
- path: "file2.txt"
stdin: "echo file?.txt"
- name: "Expansion with brackets"
test_files:
- path: "file1.txt"
- path: "file2.txt"
stdin: "echo file[12].txt"
- name: "Expansion with range"
test_files:
- path: "file1.txt"
- path: "file2.txt"
stdin: "echo file[1-2].txt"
- name: "Expansion with negation"
test_files:
- path: "file1.txt"
- path: "file2.txt"
stdin: "echo file[!2].txt"
- name: "Expansion with tilde"
env:
HOME: /some/dir
stdin: |
echo ~/file1.txt
echo ~/file1.txt:~/file1.txt
- name: "Expansion with dots"
stdin: |
echo ./file1.txt
echo ../file1.txt
- name: "Expansion with mixed patterns"
test_files:
- path: "dir/subdir/file1.txt"
stdin: "echo dir/*/file?.txt"
- name: "Expansion with escaped characters"
test_files:
- path: "file*.txt"
stdin: "echo file\\*.txt"
- name: "Pathname expansion: extglob disabled"
ignore_stderr: true
test_files:
- path: "ab.txt"
- path: "abc.txt"
- path: "abd.txt"
- path: "def.txt"
- path: "abadac.txt"
- path: "fabadac.txt"
- path: "f.txt"
- path: "script.sh"
contents: |
echo !(a*)
echo "result: $?"
echo @(abc|abd).txt
echo "result: $?"
echo ab?(c).txt
echo "result: $?"
echo *(ab|ad|ac).txt
echo "result: $?"
echo f+(ab|ad|ac).txt
echo "result: $?"
stdin: |
shopt -u extglob
chmod +x ./script.sh
./script.sh
- name: "Pathname expansion: Inverted patterns"
ignore_stderr: true
test_files:
- path: "abc.txt"
- path: "abd.txt"
- path: "def.txt"
stdin: |
shopt -s extglob
echo "1: " !(a*)
echo "2: " !(abc.txt)
echo "3: " !(abc)
echo "4: " !(*)
- name: "Pathname expansion: Degenerate inverted pattern"
test_files:
- path: "abc.txt"
- path: "abd.txt"
- path: "def.txt"
stdin: |
shopt -s extglob
echo !()
- name: "Pathname expansion: Extended patterns"
ignore_stderr: true
test_files:
- path: "abc.txt"
- path: "abd.txt"
stdin: |
shopt -s extglob
echo "1: " @(abc|abd).txt
echo "2: " @(abc.txt)
echo "3: " @(abc)
echo "4: " @(|abc.txt)
- name: "Pathname expansion: Optional patterns"
ignore_stderr: true
test_files:
- path: "ab.txt"
- path: "abc.txt"
stdin: |
shopt -s extglob
echo ab?(c).txt
- name: "Pathname expansion: Star patterns"
ignore_stderr: true
test_files:
- path: "abadac.txt"
- path: "ab.txt"
stdin: |
shopt -s extglob
echo *(ab|ad|ac).txt
- name: "Pathname expansion: Plus patterns"
ignore_stderr: true
test_files:
- path: "fabadac.txt"
- path: "f.txt"
stdin: |
shopt -s extglob
echo f+(ab|ad|ac).txt
- name: "Pathname expansion: quoting"
test_files:
- path: test.txt
- path: subdir/test.txt
stdin: |
echo "./test"*.txt
echo "subdir"/*.txt
echo "test.*"
- name: "Pathname expansion: dot files (no dotglob)"
min_oracle_version: 5.2
stdin: |
touch .file
touch .dir
shopt -u dotglob
echo "* : " *
echo "*i* : " *i*
echo "./* : " ./*
echo ".* : " .*
echo "./.*: " ./.*
- name: "Glob results are sorted"
test_files:
- path: "cherry.txt"
- path: "apple.txt"
- path: "banana.txt"
stdin: |
echo *.txt
- name: "Multiple globs on one command line"
test_files:
- path: "a.txt"
- path: "b.txt"
- path: "x.log"
- path: "y.log"
stdin: |
echo *.txt *.log
- name: "Glob does not expand in variable assignment"
test_files:
- path: "file1.txt"
- path: "file2.txt"
stdin: |
x=*.txt
echo "$x"
- name: "Glob expands in unquoted variable use"
test_files:
- path: "file1.txt"
- path: "file2.txt"
stdin: |
x=*.txt
echo $x
- name: "Glob with trailing slash matches directories"
known_failure: true
test_files:
- path: "mydir/file.txt"
- path: "myfile.txt"
stdin: |
echo */
- name: "Globstar disabled by default"
known_failure: true
test_files:
- path: "a/b/c.txt"
stdin: |
shopt -u globstar
echo **/c.txt
- name: "Globstar recursive matching"
known_failure: true
test_files:
- path: "a/b/c.txt"
- path: "a/d.txt"
- path: "e.txt"
stdin: |
shopt -s globstar
echo **/*.txt
- name: "GLOBIGNORE filters glob results"
known_failure: true
test_files:
- path: "a.txt"
- path: "b.txt"
- path: "c.txt"
stdin: |
GLOBIGNORE="b.txt"
echo *.txt
- name: "GLOBIGNORE with multiple patterns"
known_failure: true
test_files:
- path: "a.txt"
- path: "b.txt"
- path: "c.txt"
- path: "d.log"
stdin: |
GLOBIGNORE="b.txt:c.txt"
echo *.txt
echo *.log
- name: "GLOBIGNORE implicitly enables dotglob"
known_failure: true
min_oracle_version: 5.2
test_files:
- path: "a.txt"
- path: ".hidden.txt"
stdin: |
GLOBIGNORE="a.txt"
echo *.txt
- name: "Unsetting GLOBIGNORE restores behavior"
known_failure: true
test_files:
- path: "a.txt"
- path: "b.txt"
stdin: |
GLOBIGNORE="a.txt"
echo *.txt
unset GLOBIGNORE
echo *.txt
- name: "Star does not match slash in path"
test_files:
- path: "dir/file.txt"
- path: "top.txt"
stdin: |
echo *.txt
- name: "Pathname expansion: dot files (with dotglob)"
min_oracle_version: 5.2
stdin: |
touch .file
touch .dir
shopt -s dotglob
echo "* : " *
echo "*i* : " *i*
echo "./* : " ./*
echo ".* : " .*
echo "./.*: " ./.*
@@ -0,0 +1,174 @@
name: "Patterns"
cases:
- name: "Expansion with escaped characters"
test_files:
- path: "file*.txt"
stdin: "echo file\\*.txt"
- name: "Basic pattern matching"
stdin: |
test_pattern() {
local str="$1"
local pattern="$2"
if [[ "${str}" == ${pattern} ]]; then
echo "Matched: ${str} using ${pattern}"
else
echo "No match: ${str} using ${pattern}"
fi
}
test_pattern "abc" "a*"
test_pattern "abc" "b*"
test_pattern "?bc" "abc"
test_pattern "?bc" "aabc"
test_pattern "ac" "[ab]c"
test_pattern "bc" "[ab]c"
test_pattern "cc" "[ab]c"
test_pattern "ad" "[a-c]d"
test_pattern "bd" "[a-c]d"
test_pattern "dd" "[a-c]d"
test_pattern "1" "[[:alpha:]]"
test_pattern "a" "[[:alpha:]]"
test_pattern "a/b" "*b"
test_pattern "a/b" "a/b"
test_pattern "a/b" "*/*"
- name: "Extglob pattern matching"
stdin: |
shopt -s extglob
test_pattern() {
local str="$1"
local pattern="$2"
if [[ "${str}" == ${pattern} ]]; then
echo "Matched: ${str} using ${pattern}"
else
echo "No match: ${str} using ${pattern}"
fi
}
test_pattern "aabc" "!(a*)"
test_pattern "abc" "!(a*)"
test_pattern "def" "!(a*)"
test_pattern "a.foo.tar.gz" "a.!(foo|bar).tar.gz"
test_pattern "a.bar.tar.gz" "a.!(foo|bar).tar.gz"
test_pattern "a.baz.tar.gz" "a.!(foo|bar).tar.gz"
test_pattern "a.tar.tar.gz" "a.!(foo|bar).tar.gz"
test_pattern "a..tar.gz" "a.!(foo|bar).tar.gz"
test_pattern "a.tar.gz" "a.!(foo|bar).tar.gz"
test_pattern "abc" "@(abc|def)"
test_pattern "def" "@(abc|def)"
test_pattern "ghi" "@(abc|def)"
test_pattern "abc" "ab?(c)"
test_pattern "ab" "ab?(c)"
test_pattern "abd" "ab?(c)"
test_pattern "" "*(ab|ac)"
test_pattern "ab" "*(ab|ac)"
test_pattern "abab" "*(ab|ac)"
test_pattern "ad" "*(ab|ac)"
test_pattern "" "+(ab|ac)"
test_pattern "ab" "+(ab|ac)"
test_pattern "abab" "+(ab|ac)"
test_pattern "ad" "+(ab|ac)"
- name: "Extglob with escaping"
stdin: |
shopt -s extglob
[[ \( == +(\() ]] && echo "1. Matched"
[[ x == +(\() ]] && echo "2. Matched"
[[ \) == +(\)) ]] && echo "3. Matched"
[[ x == +(\)) ]] && echo "4. Matched"
- name: "Patterns: quoting"
stdin: |
[[ "abc" == "a"* ]] && echo "1. Matched"
[[ "abc" == a"*" ]] && echo "2. Matched"
[[ "abc" == "a*" ]] && echo "3. Matched"
- name: "Patterns: escaped special characters"
stdin: |
myfunc() {
if [[ $1 == \\* ]]; then
echo "Matched: '$1'"
else
echo "Did *not* match: '$1'"
fi
}
myfunc abc
myfunc "*"
- name: "Pattern matching: character ranges"
stdin: |
[[ "x" == [a-z] ]] && echo "1. Matched"
[[ "x" == [0-9] ]] && echo "2. Matched"
[[ "-" == [---] ]] && echo "3. Matched"
[[ "*" == [\*-\*] ]] && echo "4. Matched"
[[ "-" == [\*-\*] ]] && echo "5. Matched"
[[ "." == [\*-/] ]] && echo "6. Matched"
- name: "Pattern matching: invalid character ranges"
stdin: |
[[ "a" == [f-a] ]] && echo "1. Matched"
[[ "b" == [f-a] ]] && echo "2. Matched"
[[ "f" == [f-a] ]] && echo "3. Matched"
[[ "g" == [f-a] ]] && echo "4. Matched"
- name: "Pattern matching: escaped hyphen in bracket"
stdin: |
[[ "-" == [a\-\*] ]] && echo "1. Matched"
[[ "*" == [a\-\*] ]] && echo "2. Matched"
[[ "a" == [a\-\*] ]] && echo "3. Matched"
[[ "b" == [a\-\*] ]] && echo "4. Matched"
[[ "a" == [a\-f] ]] && echo "5. Matched"
[[ "b" == [a\-f] ]] && echo "6. Matched"
[[ "f" == [a\-f] ]] && echo "7. Matched"
- name: "Pattern matching: character sets"
stdin: |
[[ "x" == [abc] ]] && echo "1. Matched"
[[ "x" == [xyz] ]] && echo "2. Matched"
[[ "x" == [^xyz] ]] && echo "3. Matched"
[[ "x" == [!xyz] ]] && echo "4. Matched"
[[ "(" == [\(] ]] && echo "5. Matched"
[[ "+" == [+-] ]] && echo "6. Matched"
[[ "[" == [\[] ]] && echo "7. Matched"
[[ "]" == [\]] ]] && echo "8. Matched"
[[ "^" == [\^] ]] && echo "9. Matched"
- name: "Pattern matching: character classes"
stdin: |
[[ "1" == [[:digit:]] ]] && echo "1. Matched"
[[ "1" == [[:alpha:]] ]] && echo "2. Matched"
- name: "Pattern matching: case sensitivity"
stdin: |
shopt -u nocasematch
[[ "abc" == "ABC" ]] && echo "1. Matched"
[[ "abc" == "[A-Z]BC" ]] && echo "2. Matched"
shopt -s nocasematch
[[ "abc" == "ABC" ]] && echo "3. Matched"
[[ "abc" == "[A-Z]BC" ]] && echo "4. Matched"
- name: "Pattern matching: stars in negative extglobs"
stdin: |
shopt -s extglob
[[ 'd' == !(*d)d ]] && echo "1. Matched"
- name: "Pattern matching: quotes in character class"
stdin: |
[[ f == ['f'] ]] && echo "1. Matched"