File: grep.tf

package info (click to toggle)
tf5 5.0beta8-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,800 kB
  • sloc: ansic: 25,492; perl: 103; makefile: 82; sh: 79
file content (38 lines) | stat: -rw-r--r-- 773 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
;; simple grep

/loaded __TFLIB__/grep.tf

; Note: users should not rely on %_loaded_libs like this.  I can get away
; with this here only because this and /loaded are both internal to TF.
/if (_loaded_libs =/ "*{__TFLIB__/textutil.tf}*") \
    /echo -e %% Warning: textutil.tf and grep.tf have conflicting defintions.%;\
/endif


/def -i _fgrep = \
    /@test (strstr({*}, _pattern) >= 0) & echo({*})

/def -i fgrep = \
    /let _pattern=%1%; \
    /quote -S /_fgrep `%-1


;; glob grep

/def -i _grep = \
    /@test ({*} =/ _pattern) & echo({*})

/def -i grep = \
    /let _pattern=%1%; \
    /quote -S /_grep `%-1


;; regexp grep

/def -i _egrep = \
    /@test regmatch(_pattern, {*}) & echo({*})

/def -i egrep = \
    /let _pattern=%1%; \
    /quote -S /_egrep `%-1