spk view spk-find @ rev 161

Remove ashism ==
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Feb 26 12:27:19 2019 +0100 (2019-02-26)
parents b70363c4c5e2
children
line source
1 #!/bin/sh
2 #
3 # Spk-find - Find/search SliTaz packages and files. Read the README before
4 # adding or modifying any code in spk!
5 #
6 # Copyright (C) SliTaz GNU/Linux - BSD License
7 # Author: See AUTHORS files
8 #
9 . /usr/lib/slitaz/libspk.sh
11 #
12 # Quick coded tool to have a simple find/search packages tool for people
13 # using spk toolkit. TODO: find files, find in pkg desc for pattern, display
14 # status (installed or not).
15 #
17 find="$1"
18 cfile="/tmp/spk/count"
19 mkdir -p $(dirname $cfile)
21 #
22 # Functions
23 #
25 # Help and usage
26 usage() {
27 name=$(basename $0)
28 cat << EOT
30 $(boldify $(gettext "Usage:")) $name [package|--options]
32 $(boldify $(gettext "Options:"))
33 --short $(gettext "Short packages list format")
35 EOT
36 exit 0
37 }
39 case "$1" in
40 *help|usage) usage && exit 0 ;;
41 esac
43 newline
44 boldify $(gettext "Spk find: $find")
45 separator
47 # --files or packages
48 if [ "$files" ]; then
49 type="Files"
50 echo "TODO"
51 else
52 type="Packages"
53 IFS="|"
54 grep "$find" $pkgsdesc | while read pkg vers desc null
55 do
56 echo "$pkg" >> ${cfile}
57 echo "$(colorize 34 $pkg)${vers# }"
58 [ "$short" ] || echo " $desc"
59 done
60 unset IFS
61 fi
63 # Sep and stats
64 if [ -f "$cfile" ]; then
65 count=$(cat $cfile | wc -l)
66 color=32
67 else
68 count=0
69 color=31
70 fi
71 separator
72 boldify "$type found: $(colorize $color $count)" && newline
74 rm -rf ${cfile}
75 exit 0