Commit 6c03b6b2 authored by Vitaly Lipatov's avatar Vitaly Lipatov

add remove_from_list and regexp_exclude_list with regexp support

parent 02adfdd7
......@@ -5,27 +5,53 @@
filter_strip_spaces()
{
# possible use just
#xargs echo
sed -e "s| \+| |g" | \
sed -e "s|^ ||" | sed -e "s| \$||"
sed -e "s|^ ||" | sed -e "s| \$||"
}
strip_spaces()
{
echo $@ | filter_strip_spaces
echo "$*" | filter_strip_spaces
}
# remove_from_list "1." "11 12 21 22" -> "21 22"
remove_from_list()
{
local i
local RES=
for i in $2 ; do
echo "$i" | grep -q -w "$1" || RES="$RES $i"
done
strip_spaces "$RES"
}
# Args: LIST1 LIST2
# do_exclude_list print LIST2 with field contains in LIST1
# do_exclude_list print LIST2 exclude fields contains also in LIST1
# Example: do_exclude_list "1 3" "1 2 3 4" -> "2 4"
do_exclude_list()
{
local i
local RES=
for i in $2 ; do
echo "$1" | grep -q -w $i || RES="$RES $i"
echo "$1" | grep -q -w "$i" || RES="$RES $i"
done
echo $RES | filter_strip_spaces
strip_spaces "$RES"
}
# regexp_exclude_list "22 1." "11 12 21 22" -> "21"
regexp_exclude_list()
{
local i
local RES="$2"
for i in $1 ; do
RES=$(remove_from_list "$i" "$RES")
done
strip_spaces "$RES"
}
# drop listed options
# FIXME: do not handle args like -Uh, only -U -h separately
drop_args()
......@@ -40,7 +66,7 @@ drop_args()
initial_letter()
{
echo $1 | cut -c1
echo "$1" | head -n1 | cut -c1
}
is_dirpath()
......
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