From morganamilo at gmail.com Fri Jun 28 20:12:57 2019 From: morganamilo at gmail.com (morganamilo) Date: Fri, 28 Jun 2019 21:12:57 +0100 Subject: [PATCH 1/2] checkupdates: add -q/--quiet Message-ID: <20190628201258.20566-1-morganamilo@gmail.com> diff --git a/src/checkupdates.sh.in b/src/checkupdates.sh.in index 0885983..024243c 100644 --- a/src/checkupdates.sh.in +++ b/src/checkupdates.sh.in @@ -22,6 +22,7 @@ declare -r myname='checkupdates' declare -r myver='@PACKAGE_VERSION@' DOWNLOAD_CACHE=0 +QUIET=0 m4_include(../lib/output_format.sh) m4_include(../lib/term_colors.sh) @@ -38,14 +39,15 @@ Usage: ${myname} [options] Options: -d, --download download pending updates to the pacman cache. -h, --help display this help message and exit. + -q, --quiet only display pkgnames. Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary database. __EOF__ } -OPT_SHORT='dh' -OPT_LONG=('download' 'help') +OPT_SHORT='dhq' +OPT_LONG=('download' 'help' 'quiet') if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then exit 1 @@ -60,6 +62,8 @@ while :; do -h|--help) usage exit 0 ;; + -q|--quiet) + QUIET=1 ;; --) shift break ;; @@ -92,6 +96,9 @@ fi mapfile -t updates < <(pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]') if (( ${#updates[@]} )); then + if (( $QUIET )); then + updates=("${updates[@]%% *}") + fi printf '%s\n' "${updates[@]}" if (( DOWNLOAD_CACHE )); then sudo pacman -Sw --noconfirm "${updates[@]%% *}" --dbpath "$CHECKUPDATES_DB" --logfile /dev/null -- 2.22.0 From morganamilo at gmail.com Fri Jun 28 20:12:58 2019 From: morganamilo at gmail.com (morganamilo) Date: Fri, 28 Jun 2019 21:12:58 +0100 Subject: [PATCH 2/2] checkupdates: allow filtering the update list In-Reply-To: <20190628201258.20566-1-morganamilo@gmail.com> References: <20190628201258.20566-1-morganamilo@gmail.com> Message-ID: <20190628201258.20566-2-morganamilo@gmail.com> diff --git a/src/checkupdates.sh.in b/src/checkupdates.sh.in index 024243c..ae8197c 100644 --- a/src/checkupdates.sh.in +++ b/src/checkupdates.sh.in @@ -34,7 +34,7 @@ ${myname} v${myver} Safely print a list of pending updates -Usage: ${myname} [options] +Usage: ${myname} [options] [targets...] Options: -d, --download download pending updates to the pacman cache. @@ -93,7 +93,7 @@ if ! fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> / error 'Cannot fetch updates' exit 1 fi -mapfile -t updates < <(pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]') +mapfile -t updates < <(pacman -Qu --dbpath "$CHECKUPDATES_DB" -- "$@" 2> /dev/null | grep -v '\[.*\]') if (( ${#updates[@]} )); then if (( $QUIET )); then -- 2.22.0 From eschwartz at archlinux.org Fri Jun 28 20:20:50 2019 From: eschwartz at archlinux.org (Eli Schwartz) Date: Fri, 28 Jun 2019 16:20:50 -0400 Subject: [PATCH 1/2] checkupdates: add -q/--quiet In-Reply-To: <20190628201258.20566-1-morganamilo@gmail.com> References: <20190628201258.20566-1-morganamilo@gmail.com> Message-ID: <077c007a-229a-a004-4188-698bab5e3474@archlinux.org> On 6/28/19 4:12 PM, morganamilo wrote: What's the utility of adding this extra option, vs. just using: checkupdates | awk '{print $1}' The typical use of this script probably just cares about the exit code anyway. There are some scripts which just count the number of lines. -- Eli Schwartz Bug Wrangler and Trusted User -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 1601 bytes Desc: OpenPGP digital signature URL: From eschwartz at archlinux.org Fri Jun 28 20:24:02 2019 From: eschwartz at archlinux.org (Eli Schwartz) Date: Fri, 28 Jun 2019 16:24:02 -0400 Subject: [PATCH 2/2] checkupdates: allow filtering the update list In-Reply-To: <20190628201258.20566-2-morganamilo@gmail.com> References: <20190628201258.20566-1-morganamilo@gmail.com> <20190628201258.20566-2-morganamilo@gmail.com> Message-ID: <7ddb2597-b9de-c037-ca45-24fd3bb4ea2c@archlinux.org> On 6/28/19 4:12 PM, morganamilo wrote: What would this be used by? When do people want to only know when there are *some* updates? -- Eli Schwartz Bug Wrangler and Trusted User -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 1601 bytes Desc: OpenPGP digital signature URL: