[pacman-dev] [PATCH 2/3] pkgdelta: clean up quoting
Always quote the righthand side of expression when the == or != operator is used, unless intended as a pattern. Also, remove unnecessary quoting in variable assignments. Signed-off-by: lolilolicon <lolilolicon@gmail.com> --- scripts/pkgdelta.sh.in | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in index a0e3cee..c53098a 100644 --- a/scripts/pkgdelta.sh.in +++ b/scripts/pkgdelta.sh.in @@ -85,25 +85,25 @@ create_xdelta() deltafile read_pkginfo "$oldfile" || return 1 - oldname="$pkgname" - oldver="$pkgver" - oldarch="$arch" + oldname=$pkgname + oldver=$pkgver + oldarch=$arch read_pkginfo "$newfile" || return 1 - newname="$pkgname" - newver="$pkgver" - newarch="$arch" + newname=$pkgname + newver=$pkgver + newarch=$arch - if [[ $oldname != $newname ]]; then + if [[ $oldname != "$newname" ]]; then error "$(gettext "The package names don't match : '%s' and '%s'")" "$oldname" "$newname" return 1 fi - if [[ $oldarch != $newarch ]]; then + if [[ $oldarch != "$newarch" ]]; then error "$(gettext "The package architectures don't match : '%s' and '%s'")" "$oldarch" "$newarch" return 1 fi - if [[ $oldver == $newver ]]; then + if [[ $oldver == "$newver" ]]; then error "$(gettext "Both packages have the same version : '%s'")" "$newver" return 1 fi -- 1.7.6.4
On Wed, Sep 28, 2011 at 6:58 PM, lolilolicon <lolilolicon@gmail.com> wrote: <snip>
Also, remove unnecessary quoting in variable assignments.
actually, this one is being discouraged by #bash/wooledge.org, in favor of consistently quoting "o/ EVERYTHING"...
On Thu, Sep 29, 2011 at 1:12 AM, Martti Kühne <mysatyre@gmail.com> wrote:
On Wed, Sep 28, 2011 at 6:58 PM, lolilolicon <lolilolicon@gmail.com> wrote: <snip>
Also, remove unnecessary quoting in variable assignments.
actually, this one is being discouraged by #bash/wooledge.org, in favor of consistently quoting "o/ EVERYTHING"...
I'm not convinced unless you can give me some links. For example, code snippets in BashFAQ 13 [1] disagree with what you said. [1] http://mywiki.wooledge.org/BashFAQ/013
On Wed, Sep 28, 2011 at 07:12:26PM +0200, Martti Kühne wrote:
On Wed, Sep 28, 2011 at 6:58 PM, lolilolicon <lolilolicon@gmail.com> wrote: <snip>
Also, remove unnecessary quoting in variable assignments.
actually, this one is being discouraged by #bash/wooledge.org, in favor of consistently quoting "o/ EVERYTHING"...
In the case of assigning a variable to another variable, this can never go wrong. The quoting is not needed. dave
On Wed, Sep 28, 2011 at 11:58 AM, lolilolicon <lolilolicon@gmail.com> wrote:
Always quote the righthand side of expression when the == or != operator is used, unless intended as a pattern. +1. Also, remove unnecessary quoting in variable assignments. -1. Please don't do this.
Signed-off-by: lolilolicon <lolilolicon@gmail.com> --- scripts/pkgdelta.sh.in | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in index a0e3cee..c53098a 100644 --- a/scripts/pkgdelta.sh.in +++ b/scripts/pkgdelta.sh.in @@ -85,25 +85,25 @@ create_xdelta() deltafile
read_pkginfo "$oldfile" || return 1 - oldname="$pkgname" - oldver="$pkgver" - oldarch="$arch" + oldname=$pkgname + oldver=$pkgver + oldarch=$arch read_pkginfo "$newfile" || return 1 - newname="$pkgname" - newver="$pkgver" - newarch="$arch" + newname=$pkgname + newver=$pkgver + newarch=$arch
- if [[ $oldname != $newname ]]; then + if [[ $oldname != "$newname" ]]; then error "$(gettext "The package names don't match : '%s' and '%s'")" "$oldname" "$newname" return 1 fi
- if [[ $oldarch != $newarch ]]; then + if [[ $oldarch != "$newarch" ]]; then error "$(gettext "The package architectures don't match : '%s' and '%s'")" "$oldarch" "$newarch" return 1 fi
- if [[ $oldver == $newver ]]; then + if [[ $oldver == "$newver" ]]; then error "$(gettext "Both packages have the same version : '%s'")" "$newver" return 1 fi -- 1.7.6.4
Always quote the right-hand side of expression when the == or != operator is used, unless intended as a pattern. Signed-off-by: lolilolicon <lolilolicon@gmail.com> --- scripts/pkgdelta.sh.in | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in index a0e3cee..ef34c5b 100644 --- a/scripts/pkgdelta.sh.in +++ b/scripts/pkgdelta.sh.in @@ -93,17 +93,17 @@ create_xdelta() newver="$pkgver" newarch="$arch" - if [[ $oldname != $newname ]]; then + if [[ $oldname != "$newname" ]]; then error "$(gettext "The package names don't match : '%s' and '%s'")" "$oldname" "$newname" return 1 fi - if [[ $oldarch != $newarch ]]; then + if [[ $oldarch != "$newarch" ]]; then error "$(gettext "The package architectures don't match : '%s' and '%s'")" "$oldarch" "$newarch" return 1 fi - if [[ $oldver == $newver ]]; then + if [[ $oldver == "$newver" ]]; then error "$(gettext "Both packages have the same version : '%s'")" "$newver" return 1 fi -- 1.7.6.4
On Wed, Sep 28, 2011 at 2:05 PM, lolilolicon <lolilolicon@gmail.com> wrote:
Always quote the right-hand side of expression when the == or != operator is used, unless intended as a pattern.
Signed-off-by: lolilolicon <lolilolicon@gmail.com> Thanks, applied.
--- scripts/pkgdelta.sh.in | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in index a0e3cee..ef34c5b 100644 --- a/scripts/pkgdelta.sh.in +++ b/scripts/pkgdelta.sh.in @@ -93,17 +93,17 @@ create_xdelta() newver="$pkgver" newarch="$arch"
- if [[ $oldname != $newname ]]; then + if [[ $oldname != "$newname" ]]; then error "$(gettext "The package names don't match : '%s' and '%s'")" "$oldname" "$newname" return 1 fi
- if [[ $oldarch != $newarch ]]; then + if [[ $oldarch != "$newarch" ]]; then error "$(gettext "The package architectures don't match : '%s' and '%s'")" "$oldarch" "$newarch" return 1 fi
- if [[ $oldver == $newver ]]; then + if [[ $oldver == "$newver" ]]; then error "$(gettext "Both packages have the same version : '%s'")" "$newver" return 1 fi -- 1.7.6.4
participants (4)
-
Dan McGee
-
Dave Reisner
-
lolilolicon
-
Martti Kühne