[pacman-dev] [PATCH] makepkg: fix variable backup/restore for splitpkg
The backup and restore of variables that can be overridden while making split packages only dealt with the first element, not the whole array (FS#15010). Adjust the bash voodoo to fix it... Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index f46b7f8..e2e1604 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1262,7 +1262,7 @@ devel_update() { backup_package_variables() { for var in ${splitpkg_overrides[@]}; do indirect="${var}_backup" - eval "${indirect}=\"${!var}\"" + eval "${indirect}=(\${$var[@]})" done } @@ -1270,7 +1270,7 @@ restore_package_variables() { for var in ${splitpkg_overrides[@]}; do indirect="${var}_backup" if [ -n "${!indirect}" ]; then - eval "${var}=\"${!indirect}\"" + eval "${var}=(\${$indirect[@]})" else unset ${var} fi -- 1.6.3.2
Allan McRae wrote:
The backup and restore of variables that can be overridden while making split packages only dealt with the first element, not the whole array (FS#15010). Adjust the bash voodoo to fix it...
Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index f46b7f8..e2e1604 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1262,7 +1262,7 @@ devel_update() { backup_package_variables() { for var in ${splitpkg_overrides[@]}; do indirect="${var}_backup" - eval "${indirect}=\"${!var}\"" + eval "${indirect}=(\${$var[@]})"
Bonus points for anyone who understands what I was doing and what is being done now... All I know is that is works! :)
done }
@@ -1270,7 +1270,7 @@ restore_package_variables() { for var in ${splitpkg_overrides[@]}; do indirect="${var}_backup" if [ -n "${!indirect}" ]; then - eval "${var}=\"${!indirect}\"" + eval "${var}=(\${$indirect[@]})" else unset ${var} fi
On Mon, Jun 8, 2009 at 11:19 PM, Allan McRae<allan@archlinux.org> wrote:
- eval "${indirect}=\"${!var}\"" + eval "${indirect}=(\${$var[@]})"
Bonus points for anyone who understands what I was doing and what is being done now... All I know is that is works! :)
Well... what it was doing previously, I don't know. I can't seem to find docs on what ! does in this context. But what it's doing now is easy to understand. The non-confusing parts of the string: eval "something=( .......... )" Well, that's understandable... let's go in one step: \${....[@]} OK, that makes sense too... one more step: $var Ok, so $var is expanded (say, to 'foo'), and then we snag the contents of foo (${foo[@]}), and then put all that back in some new array, for safekeeping. Re: the ${!foo} syntax: http://tldp.org/LDP/abs/html/bashver2.html#VARREFNEW It's shorthand for this: foo="bar" bar=5 now I want the value specified by the string in $foo previously, you would do: eval "myvar=\$$foo", which equates to "myval=\$bar" and then "myval=5" The ! syntax makes this less confusing. myval=${!foo} does the exact same thing
participants (2)
-
Aaron Griffin
-
Allan McRae