[pacman-dev] [PATCH] [makepkg] Replace `echo`s with `printf`s

Dave Reisner d at falconindy.com
Tue Jan 15 22:54:30 EST 2013


On Tue, Jan 15, 2013 at 09:50:43PM -0600, William Giokas wrote:
> I was writing up a patch adding in .SRCINFO files, and noticed that the
> write_pkginfo function had some pretty random uses of echo vs. printf,
> so I switched them all to printf, including in the help section for the
> sake of formatting.
> 
> In write_pkginfo I also re-wrote the fakeroot check to be the same as
> the splitpkg check.
> 
> Signed-off-by: William Giokas <1007380 at gmail.com>
> ---

I tend to think this is just noise at this point. I was the last to
touch this sort of thing -- the echo statements I converted to printf
were meaningful. The remaining calls here are not.

>  scripts/makepkg.sh.in | 36 +++++++++++++++++-------------------
>  1 file changed, 17 insertions(+), 19 deletions(-)
> 
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index c057905..ef85dbe 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -125,7 +125,7 @@ trap_exit() {
>  	local signal=$1; shift
>  
>  	if (( ! INFAKEROOT )); then
> -		echo
> +		printf "\n"
>  		error "$@"
>  	fi
>  	[[ -n $srclinks ]] && rm -rf "$srclinks"
> @@ -993,7 +993,7 @@ get_integlist() {
>  	local integlist=()
>  
>  	for integ in md5 sha1 sha256 sha384 sha512; do
> -		local integrity_sums=($(eval echo "\${${integ}sums[@]}"))
> +		local integrity_sums=($(eval printf "\${${integ}sums[@]}\n"))

Trailing newlines here are silly, because they're just going to be
consumed by the command substitution.

>  		if [[ -n "$integrity_sums" ]]; then
>  			integlist=(${integlist[@]} $integ)
>  		fi
> @@ -1064,10 +1064,10 @@ generate_checksums() {
>  			(( ct )) && printf "%s" "$indent"
>  			printf "%s" "'$sum'"
>  			ct=$(($ct+1))
> -			(( $ct < $numsrc )) && echo
> +			(( $ct < $numsrc )) && printf "\n"
>  		done
>  
> -		echo ")"
> +		printf ")\n"
>  	done
>  }
>  
> @@ -1078,7 +1078,7 @@ check_checksums() {
>  	local correlation=0
>  	local integ required
>  	for integ in md5 sha1 sha256 sha384 sha512; do
> -		local integrity_sums=($(eval echo "\${${integ}sums[@]}"))
> +		local integrity_sums=($(eval printf "\${${integ}sums[@]}\n"))
>  		if (( ${#integrity_sums[@]} == ${#source[@]} )); then
>  			msg "$(gettext "Validating source files with %s...")" "${integ}sums"
>  			correlation=1
> @@ -1091,7 +1091,7 @@ check_checksums() {
>  				printf "%s" "    $file ... " >&2
>  
>  				if [[ ${integrity_sums[$idx]} = 'SKIP' ]]; then
> -					echo "$(gettext "Skipped")" >&2
> +					printf "$(gettext "Skipped\n")" >&2
>  					idx=$((idx + 1))
>  					continue
>  				fi
> @@ -1713,14 +1713,12 @@ write_pkginfo() {
>  	size="$(( ${size%%[^0-9]*} * 1024 ))"
>  
>  	msg2 "$(gettext "Generating %s file...")" ".PKGINFO"
> -	echo "# Generated by makepkg $makepkg_version"
> -	if (( INFAKEROOT )); then
> -		echo "# using $(fakeroot -v)"
> -	fi
> -	echo "# $(LC_ALL=C date -u)"
> +	printf "# Generated by makepkg %s\n" "$makepkg_version"
> +	(( INFAKEROOT )) && printf "# using %S\n" "$(fakeroot -v)"
> +	printf "# %s\n" "$(LC_ALL=C date -u)"
>  	printf "pkgname = %s\n" "$pkgname"
> -	(( SPLITPKG )) && echo pkgbase = $pkgbase
> -	echo "pkgver = $(get_full_version)"
> +	(( SPLITPKG )) && printf "pkgbase = %s\n" "$pkgbase"
> +	printf "pkgver = %s\n" "$(get_full_version)"
>  	printf "pkgdesc = %s\n" "${pkgdesc//+([[:space:]])/ }"
>  	printf "url = %s\n" "$url"
>  	printf "builddate = %s\n" "$builddate"
> @@ -2396,9 +2394,9 @@ m4_include(library/parseopts.sh)
>  
>  usage() {
>  	printf "makepkg (pacman) %s\n" "$makepkg_version"
> -	echo
> +	printf    "\n"
>  	printf -- "$(gettext "Usage: %s [options]")\n" "$0"
> -	echo
> +	printf    "\n"
>  	printf -- "$(gettext "Options:")\n"
>  	printf -- "$(gettext "  -A, --ignorearch Ignore incomplete %s field in %s")\n" "arch" "$BUILDSCRIPT"
>  	printf -- "$(gettext "  -c, --clean      Clean up work files after build")\n"
> @@ -2429,16 +2427,16 @@ usage() {
>  	printf -- "$(gettext "  --skipchecksums  Do not verify checksums of the source files")\n"
>  	printf -- "$(gettext "  --skipinteg      Do not perform any verification checks on source files")\n"
>  	printf -- "$(gettext "  --skippgpcheck   Do not verify source files with PGP signatures")\n"
> -	echo
> +	printf    "\n"
>  	printf -- "$(gettext "These options can be passed to %s:")\n" "pacman"
> -	echo
> +	printf    "\n"
>  	printf -- "$(gettext "  --asdeps         Install packages as non-explicitly installed")\n"
>  	printf -- "$(gettext "  --noconfirm      Do not ask for confirmation when resolving dependencies")\n"
>  	printf -- "$(gettext "  --needed         Do not reinstall the targets that are already up to date")\n"
>  	printf -- "$(gettext "  --noprogressbar  Do not show a progress bar when downloading files")\n"
> -	echo
> +	printf    "\n"
>  	printf -- "$(gettext "If %s is not specified, %s will look for '%s'")\n" "-p" "makepkg" "$BUILDSCRIPT"
> -	echo
> +	printf    "\n"
>  }
>  
>  version() {
> -- 
> 1.8.1.336.g94702dd
> 
> 


More information about the pacman-dev mailing list