Skip to content

Commit

Permalink
Fix #96, #143: Qs/q for yum, apk, dpkg
Browse files Browse the repository at this point in the history
  • Loading branch information
icy committed Jun 17, 2021
1 parent 16c31ca commit fd57f93
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## next

* `lib/yum`, `lib/dpkg`, `lib/apk`: Fix #96, #143
by adding `--quiet` option for `Qs`.

## v2.4.4

* `lib/dnf`: Minor improvements (#148)
Expand Down
13 changes: 13 additions & 0 deletions lib/00_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,16 @@ _print_supported_operations() {
done
echo
}

_quiet_field1() {
if [[ "${_TOPT}" == "" ]]; then
cat
else
awk '{print $1}'
fi
}

_quiet_field1_not_implemented() {
cat >/dev/null
_not_implemented
}
4 changes: 3 additions & 1 deletion lib/apk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ apk_Qo() {
apk info --who-owns -- "$@"
}

# apk_Qs may _not_implemented
apk_Qs() {
apk info -- "*${*}*"
apk info -- "*${*}*" \
| _quiet_field1_not_implemented
}

apk_Qu() {
Expand Down
3 changes: 2 additions & 1 deletion lib/dpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ dpkg_Qs() {
dpkg-query -W -f='${Status} ${Package}\t${Version}\t${Description}\n' \
| grep -E '^((hold)|(install)|(deinstall))' \
| sed -r -e 's#^(\w+ ){3}##g' \
| grep -Ei "${@:-.}"
| grep -Ei "${@:-.}" \
| _quiet_field1
}

# dpkg_Rs may _not_implemented
Expand Down
8 changes: 7 additions & 1 deletion lib/yum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ yum_Qi() {
}

yum_Qs() {
rpm -qa "*${*}*"
if [[ "$_TOPT" == "q" ]]; then
rpm -qa --qf "%{NAME}\\n" "*${*}*"
elif [[ "$_TOPT" == "" ]]; then
rpm -qa --qf "%{NAME} %{VERSION}\\n" "*${*}*"
else
_not_implemented
fi
}

yum_Ql() {
Expand Down

0 comments on commit fd57f93

Please sign in to comment.