[pacman-dev] [PATCH v2 9/9] pacdiff: ask to run updatedb for --locate

Dave Reisner d at falconindy.com
Mon Jul 22 23:01:56 EDT 2013


On Mon, Jul 22, 2013 at 09:23:00PM -0400, Jonathan Frazier wrote:
> Signed-off-by: Jonathan Frazier <eyeswide at gmail.com>
> ---
>  contrib/pacdiff.sh.in | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in
> index 6b5edb9..349f6b9 100644
> --- a/contrib/pacdiff.sh.in
> +++ b/contrib/pacdiff.sh.in
> @@ -28,6 +28,7 @@ diffsearchpath=${DIFFSEARCHPATH:-/etc}
>  USE_COLOR='y'
>  declare -a oldsaves
>  declare -i FIND=0 LOCATE=0 PACDB=0 OUTPUTONLY=0
> +declare -i UPDATEDB=0
>  
>  m4_include(../scripts/library/output_format.sh)
>  
> @@ -122,6 +123,20 @@ case $(( FIND+LOCATE+PACDB )) in
>  	 	usage; exit 1;;
>  esac
>  
> +if (( LOCATE )) && (( ! OUTPUTONLY )); then
> +	ask "Run updatedb? [y/n] "
> +	while read c; do
> +		case $c in
> +			Y|y) UPDATEDB=1; break;; #&& (error "updatedb failed"; exit 1);;

I'm guessing you commented this out and added the "workaround" below
because you didn't understand why the 'exit 1' didn't do anything.
You've created a subshell, so calling exit will just exit from the
subshell. You can use { ... ; } instead which groups commands without
creating a subshell. Better yet, just inline the updatedb call if you
really want to go that route. I don't see why the indirection is
needed/wanted.

> +			N|n) break;;
> +			*) ask "Invalid answer. Try again: [y/n] "; continue ;;
> +		esac
> +	done
> +fi
> +if (( UPDATEDB )); then
> +	updatedb || error "updatedb failed"

If you're going to throw an error, you should probably exit. Otherwise,
throw a warning instead and point out that results may not be accurate.

All that said, I don't really care for this feature.

> +fi
> +
>  if (( PACDB )); then
>  	if [[ ! -r @sysconfdir@/pacman.conf ]]; then
>  		error "unable to read @sysconfdir@/pacman.conf"
> -- 
> 1.8.3.2
> 
> 


More information about the pacman-dev mailing list