File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ check_ (){
4+ RESULT=" $( echo " $3 " | sed " $1 " " $4 " ) "
5+ if [ " $RESULT " != " $5 " ]; then
6+ echo " Test failed: $2 " >&2
7+ echo " ----- expected -----
8+ $5
9+ ----- returned -----"
10+ echo " $RESULT "
11+ exit 1
12+ fi
13+ }
14+
15+ # Check BRE
16+ checkb (){
17+ check_ " -e" " $@ "
18+ }
19+ # Check ERE
20+ checke (){
21+ check_ " -E" " $@ "
22+ }
23+ # Check both
24+ check (){
25+ checkb " $@ "
26+ checke " $@ "
27+ }
28+
29+ # Basics
30+
31+ check ' Custom character class' \
32+ ' adn
33+ aqv' ' s/[b-eq]/x/g' \
34+ ' axn
35+ axv'
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ check (){
4+ FILE=" $( mktemp) "
5+ echo " $2 " > " $FILE "
6+ exec 3<<< " $3
7+ :w! $FILE
8+ :q!"
9+ vi - < " $FILE " 2< & 3-
10+ if [ " $( cat " $FILE " ) " != " $4 " ]; then
11+ echo " Test failed: $1 " >&2
12+ echo " ----- expected -----
13+ $4
14+ ----- returned -----"
15+ cat " $FILE "
16+ rm " $FILE "
17+ exit 1
18+ fi
19+ rm " $FILE "
20+ }
21+
22+ # Basics
23+
24+ check ' Custom character class' \
25+ ' adn
26+ aqv' ' :%s/[b-eq]/x/g' \
27+ ' axn
28+ axv'
You can’t perform that action at this time.
0 commit comments