paclist: Allow listing packages from multiple repos at once

Message ID 20190728103442.18603-1-rustand.lars@gmail.com
State Superseded, archived
Headers show
Series paclist: Allow listing packages from multiple repos at once | expand

Commit Message

Lars Rustand July 28, 2019, 10:34 a.m. UTC
Signed-off-by: Lars Rustand <rustand.lars@gmail.com>
---
 src/paclist.sh.in | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Johannes Löthberg Aug. 4, 2019, 4:32 p.m. UTC | #1
Hey,

Sorry for the delay, haven't had much free time lately...

Excerpts from Lars Rustand's message of July 28, 2019 12:34:
> Signed-off-by: Lars Rustand <rustand.lars@gmail.com>
> ---
>  src/paclist.sh.in | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/paclist.sh.in b/src/paclist.sh.in
> index efd47af..4fd7e5e 100644
> --- a/src/paclist.sh.in
> +++ b/src/paclist.sh.in
> @@ -25,7 +25,7 @@ usage() {
>  	echo
>  	printf "List all packages installed from a given repository\n" "${myname}"
>  	echo
> -	printf "Usage: %s <repository>\n" "${myname}"
> +	printf "Usage: %s <repository> ...\n" "${myname}"
>  	echo
>  	printf "Example: %s testing\n" "${myname}"
>  }
> @@ -49,8 +49,10 @@ elif [[ $1 = -@(V|-version) ]]; then
>  	exit 0
>  fi
>  
> -pacman -Sl $1 | awk '/\[.*[[:alpha:]]+]$/ {print $2,$3};
> -                     /\[.*[[:digit:]]+]$/ {print $2,substr($NF, 1, length($NF) - 1)}'
> +for repo in "$@"; do
> +	pacman -Sl $repo | awk '/\[.*[[:alpha:]]+]$/ {print $2,$3};
> +							/\[.*[[:digit:]]+]$/ {print $2,substr($NF, 1, length($NF) - 1)}'
> +done
>  

-Sl accepts multiple repos, so this should just be changed to "$@" 
instead of $1.

>  # exit with pacman's return value, not awk's
>  exit ${PIPESTATUS[0]}
> -- 
> 2.22.0
>

Patch

diff --git a/src/paclist.sh.in b/src/paclist.sh.in
index efd47af..4fd7e5e 100644
--- a/src/paclist.sh.in
+++ b/src/paclist.sh.in
@@ -25,7 +25,7 @@  usage() {
 	echo
 	printf "List all packages installed from a given repository\n" "${myname}"
 	echo
-	printf "Usage: %s <repository>\n" "${myname}"
+	printf "Usage: %s <repository> ...\n" "${myname}"
 	echo
 	printf "Example: %s testing\n" "${myname}"
 }
@@ -49,8 +49,10 @@  elif [[ $1 = -@(V|-version) ]]; then
 	exit 0
 fi
 
-pacman -Sl $1 | awk '/\[.*[[:alpha:]]+]$/ {print $2,$3};
-                     /\[.*[[:digit:]]+]$/ {print $2,substr($NF, 1, length($NF) - 1)}'
+for repo in "$@"; do
+	pacman -Sl $repo | awk '/\[.*[[:alpha:]]+]$/ {print $2,$3};
+							/\[.*[[:digit:]]+]$/ {print $2,substr($NF, 1, length($NF) - 1)}'
+done
 
 # exit with pacman's return value, not awk's
 exit ${PIPESTATUS[0]}