Commit 9caedb2c authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-search: introduce grep extra args in search

parent 4f496fdb
......@@ -80,6 +80,7 @@ show_command_only=
epm_cmd=
pkg_files=
pkg_names=
quoted_args=
progname="${0##*/}"
......@@ -290,6 +291,7 @@ for opt in "$@" ; do
else
pkg_names="$pkg_names $opt"
fi
quoted_args="$quoted_args \"$opt\""
done
pkg_files=$(strip_spaces "$pkg_files")
......
......@@ -17,13 +17,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# copied from korinf/tools/run-script/scripts/search
epm_search()
__epm_search_output()
{
local CMD
[ -n "$pkg_filenames" ] || fatal "Run search without names"
local CMD
local string="$1"
case $PMTYPE in
apt-rpm|apt-dpkg)
CMD="apt-cache search"
......@@ -56,7 +53,7 @@ case $PMTYPE in
CMD="mpkg search"
;;
npackd)
docmd npackdcl search --query="$pkg_filenames" --status=all
docmd npackdcl search --query="$string" --status=all
return
;;
chocolatey)
......@@ -65,7 +62,7 @@ case $PMTYPE in
slackpkg)
# FIXME
echo "FIXME: need case insensitive search"
docmd_foreach "/usr/sbin/slackpkg search" $pkg_filenames
docmd_foreach "/usr/sbin/slackpkg search" $string
return
;;
homebrew)
......@@ -76,6 +73,31 @@ case $PMTYPE in
;;
esac
docmd $CMD $pkg_filenames
docmd $CMD $string
}
# produce grep sequence
__epm_search_make_grep()
{
local i
local string="$1"
shift
echo -n "\"$string\""
for i in $@ ; do
local NOR=${i/^/}
if [ "$NOR" = "$i" ] ; then
echo -n " | grep -- \"$i\""
else
echo -n " | grep -v -- \"$NOR\""
fi
done
}
# copied from korinf/tools/run-script/scripts/search
epm_search()
{
[ -n "$pkg_filenames" ] || fatal "Run search without any string"
# FIXME: do it better
eval "__epm_search_output $(eval __epm_search_make_grep $quoted_args)"
}
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