[pacman-dev] [PATCH] makepkg: revert bash4-ism
Commit 3d67d9b1 introduced a bash4 string manipulation. Revert that in order retain compatibility with bash-3.2 which is still widely used. Signed-off-by: Allan McRae <allan@archlinux.org> --- This is for the maint branch scripts/makepkg.sh.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c6bc738..3bc6019 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1665,7 +1665,7 @@ if (( CLEANCACHE )); then echo -n "$(gettext " Are you sure you wish to do this? ")" echo -n "$(gettext "[y/N]")" read answer - answer="${answer^^}" + answer=$(echo $answer | tr '[:lower:]' '[:upper:]') if [[ $answer = $(gettext YES) || $answer = $(gettext Y) ]]; then rm "$SRCDEST"/* if (( $? )); then -- 1.7.1
On 20/06/10 23:30, Allan McRae wrote:
Commit 3d67d9b1 introduced a bash4 string manipulation. Revert that in order retain compatibility with bash-3.2 which is still widely used.
Signed-off-by: Allan McRae<allan@archlinux.org> ---
This is for the maint branch
There is a bunch more ${i,,} style bash4isms that I am removing now. A new patch will be forwarded soon. Allan
Commit 3d67d9b1 introduced multiple bash4 string manipulations. Revert those in order retain compatibility with bash-3.2 which is still widely used. Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c6bc738..5b8d703 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -265,11 +265,11 @@ check_buildenv() { # ? - not found ## in_opt_array() { - local needle="${1,,}"; shift + local needle=$(echo $1 | tr '[:upper:]' '[:lower:]'); shift local opt for opt in "$@"; do - opt="${opt,,}" + opt=$(echo $opt | tr '[:upper:]' '[:lower:]') if [[ $opt = $needle ]]; then echo 'y' # Enabled return @@ -554,7 +554,7 @@ generate_checksums() { local integ for integ in ${integlist[@]}; do - integ="${integ,,}" + integ=$(echo $integ | tr '[:upper:]' '[:lower:]') case "$integ" in md5|sha1|sha256|sha384|sha512) : ;; *) @@ -617,7 +617,7 @@ check_checksums() { fi if (( $found )) ; then - local expectedsum="${integrity_sums[$idx],,}" + local expectedsum=$(echo ${integrity_sums[$idx]} | tr '[:upper:]' '[:lower:]') local realsum="$(openssl dgst -${integ} "$file")" realsum="${realsum##* }" if [[ $expectedsum = $realsum ]]; then @@ -1665,7 +1665,7 @@ if (( CLEANCACHE )); then echo -n "$(gettext " Are you sure you wish to do this? ")" echo -n "$(gettext "[y/N]")" read answer - answer="${answer^^}" + answer=$(echo $answer | tr '[:lower:]' '[:upper:]') if [[ $answer = $(gettext YES) || $answer = $(gettext Y) ]]; then rm "$SRCDEST"/* if (( $? )); then -- 1.7.1
On 20.06.2010 16:39, Allan McRae wrote:
Commit 3d67d9b1 introduced multiple bash4 string manipulations. Revert those in order retain compatibility with bash-3.2 which is still widely used.
If you want to make it bash 3 compatible again, you also have to replace "&> /dev/null" with ">/dev/null 2>&1".
On 21/06/10 00:37, Cedric Staniewski wrote:
On 20.06.2010 16:39, Allan McRae wrote:
Commit 3d67d9b1 introduced multiple bash4 string manipulations. Revert those in order retain compatibility with bash-3.2 which is still widely used.
If you want to make it bash 3 compatible again, you also have to replace "&> /dev/null" with ">/dev/null 2>&1".
Thanks. I missed that when I was reading up on bash-4 specific features. We need to keep bash-3.2 compatibility as that is the latest bash version on Cygwin and OSX where we do have pacman users. Allan
On Sun, Jun 20, 2010 at 9:00 AM, Allan McRae <allan@archlinux.org> wrote:
Commit 3d67d9b1 introduced a bash4 string manipulation. Revert that in order retain compatibility with bash-3.2 which is still widely used.
Signed-off-by: Allan McRae <allan@archlinux.org> ---
This is for the maint branch
scripts/makepkg.sh.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c6bc738..3bc6019 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1665,7 +1665,7 @@ if (( CLEANCACHE )); then echo -n "$(gettext " Are you sure you wish to do this? ")" echo -n "$(gettext "[y/N]")" read answer - answer="${answer^^}" + answer=$(echo $answer | tr '[:lower:]' '[:upper:]')
Before you change all of these to tr(1), please use a here-string instead of a less elegant `echo | foo` subshell. $ tr '[lower:]' '[upper:]' <<<"$answer" Notice that answer should be quoted because it's unfiltered user data... And also keep in mind that most situations were echo | foo would be used in makepkg are already using a here-string. here-strings (<<<) are bash32 compat. Andres P
if [[ $answer = $(gettext YES) || $answer = $(gettext Y) ]]; then rm "$SRCDEST"/* if (( $? )); then -- 1.7.1
On Sun, Jun 20, 2010 at 1:01 PM, Andres P <aepd87@gmail.com> wrote:
And also keep in mind that most situations were echo | foo would be used in makepkg are already using a here-string.
Sorry, this isn't true. makepkg isn't using <<<; maybe it was an old commit. Anyway, the recommendation still stands since it avoids subshells and yadda yadda... Andres P
On 21/06/10 03:31, Andres P wrote:
On Sun, Jun 20, 2010 at 9:00 AM, Allan McRae<allan@archlinux.org> wrote:
Commit 3d67d9b1 introduced a bash4 string manipulation. Revert that in order retain compatibility with bash-3.2 which is still widely used.
Signed-off-by: Allan McRae<allan@archlinux.org> ---
This is for the maint branch
scripts/makepkg.sh.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c6bc738..3bc6019 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1665,7 +1665,7 @@ if (( CLEANCACHE )); then echo -n "$(gettext " Are you sure you wish to do this? ")" echo -n "$(gettext "[y/N]")" read answer - answer="${answer^^}" + answer=$(echo $answer | tr '[:lower:]' '[:upper:]')
Before you change all of these to tr(1), please use a here-string instead of a less elegant `echo | foo` subshell.
$ tr '[lower:]' '[upper:]'<<<"$answer"
Notice that answer should be quoted because it's unfiltered user data...
And also keep in mind that most situations were echo | foo would be used in makepkg are already using a here-string.
here-strings (<<<) are bash32 compat.
patch adjusted on my working-maint branch. Allan
participants (3)
-
Allan McRae
-
Andres P
-
Cedric Staniewski