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