Commit a6e078ae authored by Vitaly Lipatov's avatar Vitaly Lipatov

tools_estrlist: update to 0.5

parent c04486cd
...@@ -63,19 +63,25 @@ has_space() ...@@ -63,19 +63,25 @@ has_space()
list() list()
{ {
local i local i
set -f
for i in $@ ; do for i in $@ ; do
echo "$i" echo "$i"
done done
set +f
} }
count() count()
{ {
list $@ | wc -l set -f
list $@ | wc -l
set +f
} }
union() union()
{ {
strip_spaces $(list $@ | sort -u) set -f
strip_spaces $(list $@ | sort -u)
set +f
} }
intersection() intersection()
...@@ -107,7 +113,7 @@ match() ...@@ -107,7 +113,7 @@ match()
{ {
local wd="$1" local wd="$1"
shift shift
echo "$*" | egrep -q -- "$wd" echo "$*" | grep -E -q -- "$wd"
} }
...@@ -116,9 +122,11 @@ reg_remove() ...@@ -116,9 +122,11 @@ reg_remove()
{ {
local i local i
local RES= local RES=
set -f
for i in $2 ; do for i in $2 ; do
echo "$i" | grep -q "^$1$" || RES="$RES $i" echo "$i" | grep -q "^$1$" || RES="$RES $i"
done done
set +f
strip_spaces "$RES" strip_spaces "$RES"
} }
...@@ -127,9 +135,11 @@ reg_wordremove() ...@@ -127,9 +135,11 @@ reg_wordremove()
{ {
local i local i
local RES="" local RES=""
set -f
for i in $2 ; do for i in $2 ; do
echo "$i" | grep -q -w "$1" || RES="$RES $i" echo "$i" | grep -q -w "$1" || RES="$RES $i"
done done
set +f
strip_spaces "$RES" strip_spaces "$RES"
} }
...@@ -150,9 +160,11 @@ exclude() ...@@ -150,9 +160,11 @@ exclude()
{ {
local i local i
local RES="$2" local RES="$2"
set -f
for i in $1 ; do for i in $1 ; do
RES="$(reg_rqremove "$i" "$RES")" RES="$(reg_rqremove "$i" "$RES")"
done done
set +f
strip_spaces "$RES" strip_spaces "$RES"
} }
...@@ -161,9 +173,11 @@ reg_exclude() ...@@ -161,9 +173,11 @@ reg_exclude()
{ {
local i local i
local RES="$2" local RES="$2"
set -f
for i in $1 ; do for i in $1 ; do
RES="$(reg_remove "$i" "$RES")" RES="$(reg_remove "$i" "$RES")"
done done
set +f
strip_spaces "$RES" strip_spaces "$RES"
} }
...@@ -172,18 +186,22 @@ reg_wordexclude() ...@@ -172,18 +186,22 @@ reg_wordexclude()
{ {
local i local i
local RES="$2" local RES="$2"
set -f
for i in $1 ; do for i in $1 ; do
RES=$(reg_wordremove "$i" "$RES") RES=$(reg_wordremove "$i" "$RES")
done done
set +f
strip_spaces "$RES" strip_spaces "$RES"
} }
if_contain() if_contain()
{ {
local i local i
set -f
for i in $2 ; do for i in $2 ; do
[ "$i" = "$1" ] && return [ "$i" = "$1" ] && return
done done
set +f
return 1 return 1
} }
...@@ -191,12 +209,14 @@ difference() ...@@ -191,12 +209,14 @@ difference()
{ {
local RES="" local RES=""
local i local i
set -f
for i in $1 ; do for i in $1 ; do
if_contain $i "$2" || RES="$RES $i" if_contain $i "$2" || RES="$RES $i"
done done
for i in $2 ; do for i in $2 ; do
if_contain $i "$1" || RES="$RES $i" if_contain $i "$1" || RES="$RES $i"
done done
set +f
strip_spaces "$RES" strip_spaces "$RES"
} }
...@@ -207,9 +227,11 @@ reg_include() ...@@ -207,9 +227,11 @@ reg_include()
{ {
local i local i
local RES="" local RES=""
set -f
for i in $2 ; do for i in $2 ; do
echo "$i" | grep -q -w "$1" && RES="$RES $i" echo "$i" | grep -q -w "$1" && RES="$RES $i"
done done
set +f
strip_spaces "$RES" strip_spaces "$RES"
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment