From bff61cf9e1b2fd17eb971c1e5253f4d84eaedd3a Mon Sep 17 00:00:00 2001 From: Clint Adams Date: Mon, 2 Jul 2001 19:39:34 +0000 Subject: 15211: zsh/pcre module --- Functions/Example/zpgrep | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Functions/Example/zpgrep (limited to 'Functions') diff --git a/Functions/Example/zpgrep b/Functions/Example/zpgrep new file mode 100644 index 000000000..8b1edaa1c --- /dev/null +++ b/Functions/Example/zpgrep @@ -0,0 +1,25 @@ +# Usage: zpgrep ... +# + +zpgrep() { +local file pattern + +pattern=$1 +shift + +if ((! ARGC)) then + set -- - +fi + +pcre_compile $pattern +pcre_study + +for file +do + if [[ "$file" == - ]] then + while read -u0 buf; do pcre_match $buf && print $buf; done + else + while read -u0 buf; do pcre_match $buf && print $buf; done < "$file" + fi +done +} -- cgit 1.4.1