⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glob.tests

📁 android-w.song.android.widget
💻 TESTS
字号:
export LC_COLLATE=C## test the shell globbing#expect(){	echo expect "$@"}# First, a test that bash-2.01.1 fails${THIS_SH} ./glob1.subMYDIR=$PWD	# save where we areTESTDIR=/tmp/glob-testmkdir $TESTDIRbuiltin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }rm -rf *touch a b c d abc abd abe bb bcd ca cb dd de Bewaremkdir bdir# see if `regular' globbing works rightexpect '<a> <abc> <abd> <abe> <X*>'recho a* X*expect '<a> <abc> <abd> <abe>'recho \a*# see if null glob expansion worksshopt -s nullglobexpect '<a> <abc> <abd> <abe>'recho a* X*shopt -u nullglob# see if the failglob option worksmkdir tmptouch tmp/l1 tmp/l2 tmp/l3builtin echo tmp/l[12] tmp/*4 tmp/*3shopt -s failglobbuiltin echo tmp/l[12] tmp/*4 tmp/*3rm -r tmpshopt -u failglob# see if the code that expands directories only worksexpect '<bdir/>'recho b*/# Test quoted and unquoted globbing charactersexpect '<*>'recho \*expect '<a*>'recho 'a*'expect '<a*>'recho a\*expect '<c> <ca> <cb> <a*> <*q*>'recho c* a\* *q*expect '<**>'recho "*"*expect '<**>'recho \**expect '<\.\./*/>'recho "\.\./*/"expect '<s/\..*//>'recho 's/\..*//'# Pattern from Larry Wall's Configure that caused bash to blow upexpect '</^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/>'recho "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/"# Make sure character classes work properlyexpect '<abc> <abd> <abe> <bb> <cb>'recho [a-c]b*expect '<abd> <abe> <bb> <bcd> <bdir> <ca> <cb> <dd> <de>'recho [a-y]*[^c]expect '<abd> <abe>'recho a*[^c]touch a-b aXbexpect '<a-b> <aXb>'recho a[X-]btouch .x .yexpect '<Beware> <d> <dd> <de>'recho [^a-c]*# Make sure that filenames with embedded globbing characters are handled# properlymkdir a\*b> a\*b/oooexpect '<a*b/ooo>'recho a\*b/*expect '<a*b/ooo>'recho a\*?/*expect '<no match>'cmd='echo !7'case "$cmd" in*\\!*) echo match ;;*) echo no match ;;esacexpect '<not there>'file='r.*'case $file in*.\*) echo not there ;;*) echo there ;;esac# examples from the Posix.2 spec (d11.2, p. 243)expect '<abc>'recho a[b]cexpect '<abc>'recho a["b"]cexpect '<abc>'recho a[\b]cexpect '<abc>'recho a?cexpect '<match 1>'case abc ina"b"c)	echo 'match 1' ;;*)	echo 'BAD match 1' ;;esacexpect '<match 2>'case abc ina*c)	echo 'match 2' ;;*)	echo 'BAD match 2' ;;esacexpect '<ok 1>'case abc in"a?c")	echo 'bad 1' ;;*)	echo 'ok 1' ;;esacexpect '<ok 2>'case abc ina\*c)	echo 'bad 2' ;;*)	echo 'ok 2' ;;esacexpect '<ok 3>'case abc ina\[b]c)	echo 'bad 3' ;;*)	echo 'ok 3' ;;esacexpect '<ok 4>'case "$nosuchvar" in"") 	echo 'ok 4' ;;*)	echo 'bad 4' ;;esac# This is very odd, but sh and ksh seem to agreeexpect '<ok 5>'case abc ina["\b"]c) echo 'ok 5' ;;*)	echo 'bad 5' ;;esacmkdir manmkdir man/man1touch man/man1/bash.1expect '<man/man1/bash.1>'recho */man*/bash.*expect '<man/man1/bash.1>'recho $(echo */man*/bash.*)expect '<man/man1/bash.1>'recho "$(echo */man*/bash.*)"# tests with multiple `*'scase abc ina***c)	echo ok 1;;esaccase abc ina*****?c)	echo ok 2;;esaccase abc in?*****??)	echo ok 3;;esaccase abc in*****??)	echo ok 4;;esaccase abc in*****??c)	echo ok 5;;esaccase abc in?*****?c)	echo ok 6;;esaccase abc in?***?****c)	echo ok 7;;esaccase abc in?***?****?)	echo ok 8;;esaccase abc in?***?****)	echo ok 9;;esaccase abc in*******c)	echo ok 10;;esaccase abc in*******?)	echo ok 11;;esaccase abcdecdhjk ina*cd**?**??k)	echo ok 20;;esaccase abcdecdhjk ina**?**cd**?**??k)	echo ok 21;;esaccase abcdecdhjk ina**?**cd**?**??k***)	echo ok 22;;esaccase abcdecdhjk ina**?**cd**?**??***k)	echo ok 23;;esaccase abcdecdhjk ina**?**cd**?**??***k**)	echo ok 24;;esaccase abcdecdhjk ina****c**?**??*****)	echo ok 25;;esaccase '-' in[-abc])	echo ok 26 ;;esaccase '-' in[abc-]) echo ok 27 ;;esaccase '\' in\\)	echo ok 28 ;;esaccase '\' in[\\])	echo ok 29 ;;esaccase '\' in'\')	echo ok 30 ;;esaccase '[' in[[])	echo ok 31 ;;esac# a `[' without a closing `]' is just another character to match, in the# bash implementationcase '[' in[)	echo ok 32 ;;esaccase '[abc' in[*)	echo 'ok 33';;esac# a right bracket shall lose its special meaning and represent itself in# a bracket expression if it occurs first in the list.  -- POSIX.2 2.8.3.2case ']' in[]])	echo ok 34 ;;esaccase '-' in[]-])	echo ok 35 ;;esac# a backslash should just escape the next character in this contextcase p in[a-\z])	echo ok 36 ;;esac# this was a bug in all versions up to bash-2.04-releasecase "/tmp" in[/\\]*) echo ok 37 ;;esac# none of these should output anythingcase abc in??**********?****?)	echo bad 1;;esaccase abc in??**********?****c)	echo bad 2;;esaccase abc in?************c****?****)	echo bad 3;;esaccase abc in*c*?**)	echo bad 4;;esaccase abc ina*****c*?**)	echo bad 5;;esaccase abc ina********???*******)	echo bad 6;;esaccase 'a' in[])	echo bad 7 ;;esaccase '[' in[abc)	echo bad 8;;esac# let's start testing the case-insensitive globbing coderecho b*shopt -s nocaseglobrecho b*recho [b]*shopt -u nocaseglob# make sure set -f works rightset -frecho *set +f# test out the GLOBIGNORE codeGLOBIGNORE='.*:*c:*e:?'recho *GLOBIGNORE='.*:*b:*d:?'recho *# see if GLOBIGNORE can substitute for `set -f'GLOBIGNORE='.*:*'recho *unset GLOBIGNOREexpect '<man/man1/bash.1>'recho */man*/bash.*# make sure null values for GLOBIGNORE have no effectGLOBIGNORE=expect '<man/man1/bash.1>'recho */man*/bash.*# this is for the benefit of pure coverage, so it writes the pcv file# in the right place, and for gprofbuiltin cd $MYDIRrm -rf $TESTDIRexit 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -