FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 03-09-2012, 02:20 PM
Dave Reisner
 
Default makepkg: use printf rather than echo to output variable

On Fri, Mar 09, 2012 at 05:59:05PM +1000, Allan McRae wrote:
> Signed-off-by: Allan McRae <allan@archlinux.org>
> ---
> scripts/makepkg.sh.in | 62 ++++++++++++++++++++++++-------------------------
> 1 file changed, 31 insertions(+), 31 deletions(-)
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 601c7e2..384e142 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -211,7 +211,7 @@ get_filepath() {
> return 1
> fi
>
> - echo "$file"
> + printf "%s
" "$file"
> }
>
> # Print 'source not found' error message and exit makepkg
> @@ -226,13 +226,13 @@ get_filename() {
> # if a filename is specified, use it
> local filename="${1%%::*}"
> # if it is just an URL, we only keep the last component
> - echo "${filename##*/}"
> + printf "%s
" "${filename##*/}"
> }
>
> # extract the URL from a source entry
> get_url() {
> # strip an eventual filename
> - echo "${1#*::}"
> + printf "%s
" "${1#*::}"
> }
>
> ##
> @@ -242,9 +242,9 @@ get_url() {
> get_full_version() {
> if [[ -z $1 ]]; then
> if [[ $epoch ]] && (( ! $epoch )); then
> - echo $pkgver-$pkgrel
> + printf "%s
" $pkgver-$pkgrel

There's a few instances of these var expansions being unquoted. Can we
fix that while we're touching these lines?

> else
> - echo $epoch:$pkgver-$pkgrel
> + printf "%s
" $epoch:$pkgver-$pkgrel
> fi
> else
> for i in pkgver pkgrel epoch; do
> @@ -253,9 +253,9 @@ get_full_version() {
> [[ -z ${!indirect} ]] && eval ${indirect}="${!i}"
> done
> if (( ! $epoch_override )); then
> - echo $pkgver_override-$pkgrel_override
> + printf "%s
" $pkgver_override-$pkgrel_override
> else
> - echo $epoch_override:$pkgver_override-$pkgrel_override
> + printf "%s
" $epoch_override:$pkgver_override-$pkgrel_override
> fi
> fi
> }
> @@ -272,14 +272,14 @@ get_full_version() {
> check_option() {
> local ret=$(in_opt_array "$1" ${options[@]})
> if [[ $ret != '?' ]]; then
> - echo $ret
> + printf "%s
" "$ret"
> return
> fi
>
> # fall back to makepkg.conf options
> ret=$(in_opt_array "$1" ${OPTIONS[@]})
> if [[ $ret != '?' ]]; then
> - echo $ret
> + printf "%s
" "$ret"
> return
> fi
>
> @@ -379,7 +379,7 @@ get_downloadclient() {
> exit 1 # $E_MISSING_PROGRAM
> fi
>
> - echo "$agent"
> + printf "%s
" "$agent"
> }
>
> download_file() {
> @@ -446,7 +446,7 @@ check_deps() {
> set -E
>
> if (( ret == 127 )); then #unresolved deps
> - echo "$pmout"
> + printf "%s
" "$pmout"
> elif (( ret )); then
> error "$(gettext "'%s' returned a fatal error (%i): %s")" "$PACMAN" "$ret" "$pmout"
> return "$ret"
> @@ -594,9 +594,9 @@ get_integlist() {
> done
>
> if (( ${#integlist[@]} > 0 )); then
> - echo ${integlist[@]}
> + printf "%s
" ${integlist[@]}
> else
> - echo ${INTEGRITY_CHECK[@]}
> + printf "%s
" ${INTEGRITY_CHECK[@]}
> fi
> }
>
> @@ -627,7 +627,7 @@ generate_checksums() {
>
> local ct=0
> local numsrc=${#source[@]}
> - echo -n "${integ}sums=("
> + printf "%s" "${integ}sums=("
>
> local i
> local indent='
> @@ -641,8 +641,8 @@ generate_checksums() {
> file="$(get_filepath "$netfile")" || missing_source_file "$netfile"
> local sum="$(openssl dgst -${integ} "$file")"
> sum=${sum##* }
> - (( ct )) && echo -n "$indent"
> - echo -n "'$sum'"
> + (( ct )) && printf "%s" "$indent"
> + printf "%s" "'$sum'"
> ct=$(($ct+1))
> (( $ct < $numsrc )) && echo
> done
> @@ -668,7 +668,7 @@ check_checksums() {
> for file in "${source[@]}"; do
> local found=1
> file="$(get_filename "$file")"
> - echo -n " $file ... " >&2
> + printf "%s" " $file ... " >&2
>
> if ! file="$(get_filepath "$file")"; then
> printf -- "$(gettext "NOT FOUND")
" >&2
> @@ -1082,7 +1082,7 @@ find_libdepends() {
> if in_array "${soname}" ${depends[@]}; then
> if ! in_array "${soname}=${soversion}-${soarch}" ${libdepends[@]}; then
> # libfoo.so=1-64
> - echo "${soname}=${soversion}-${soarch}"
> + printf "%s" "${soname}=${soversion}-${soarch}"
> libdepends=(${libdepends[@]} "${soname}=${soversion}-${soarch}")
> fi
> fi
> @@ -1137,7 +1137,7 @@ find_libprovides() {
> fi
> done
>
> - echo ${libprovides[@]}
> + printf "%s" ${libprovides[@]}
> }
>
> check_license() {
> @@ -1164,15 +1164,15 @@ write_pkginfo() {
> echo "# using $(fakeroot -v)"
> fi
> echo "# $(LC_ALL=C date -u)"
> - echo "pkgname = $1"
> + printf "pkgname = %s
" "$1"
> (( SPLITPKG )) && echo pkgbase = $pkgbase
> echo "pkgver = $(get_full_version)"
> - echo "pkgdesc = $pkgdesc"
> - echo "url = $url"
> - echo "builddate = $builddate"
> - echo "packager = $packager"
> - echo "size = $size"
> - echo "arch = $PKGARCH"
> + printf "pkgdesc = %s
" "$pkgdesc"
> + printf "url = %s
" "$url"
> + printf "builddate = %s
" "$builddate"
> + printf "packager = %s
" "$packager"
> + printf "size = %s
" "$size"
> + printf "arch = %s
" "$PKGARCH"
>
> [[ $license ]] && printf "license = %s
" "${license[@]}"
> [[ $replaces ]] && printf "replaces = %s
" "${replaces[@]}"
> @@ -1200,7 +1200,7 @@ write_pkginfo() {
> return 1
> fi
> else
> - echo "depend = $it"
> + printf "depend = %s
" "$it"
> fi
> done
>
> @@ -1208,9 +1208,9 @@ write_pkginfo() {
> local ret="$(check_option $it)"
> if [[ $ret != "?" ]]; then
> if [[ $ret = "y" ]]; then
> - echo "makepkgopt = $it"
> + printf "makepkgopt = %s
" "$it"
> else
> - echo "makepkgopt = !$it"
> + printf "makepkgopt = %s
" "!$it"
> fi
> fi
> done
> @@ -1851,7 +1851,7 @@ canonicalize_path() {
> pwd -P
> )
> else
> - echo "$path"
> + printf "%s
" "$path"
> fi
> }
>
> @@ -1916,7 +1916,7 @@ There is NO WARRANTY, to the extent permitted by law.
")"
> # determine whether we have gettext; make it a no-op if we do not
> if ! type -p gettext >/dev/null; then
> gettext() {
> - echo "$@"
> + printf "%s
" "$@"
> }
> fi
>
> --
> 1.7.9.3
>
>
 
Old 03-10-2012, 10:13 AM
Allan McRae
 
Default makepkg: use printf rather than echo to output variable

On 10/03/12 01:20, Dave Reisner wrote:
> On Fri, Mar 09, 2012 at 05:59:05PM +1000, Allan McRae wrote:
>> Signed-off-by: Allan McRae <allan@archlinux.org>
>> ---
>> scripts/makepkg.sh.in | 62 ++++++++++++++++++++++++-------------------------
>> 1 file changed, 31 insertions(+), 31 deletions(-)
>>
>> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
>> index 601c7e2..384e142 100644

<snip>

>>
>> ##
>> @@ -242,9 +242,9 @@ get_url() {
>> get_full_version() {
>> if [[ -z $1 ]]; then
>> if [[ $epoch ]] && (( ! $epoch )); then
>> - echo $pkgver-$pkgrel
>> + printf "%s
" $pkgver-$pkgrel
>
> There's a few instances of these var expansions being unquoted. Can we
> fix that while we're touching these lines?
>

Done, and throughout makepkg. On my working branch.

Allan
 

Thread Tools




All times are GMT. The time now is 05:54 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org