[pacman-dev] [PATCH 2/3] scripts/*: Declare several constant variables read-only

Lukas Fleischer archlinux at cryptocrack.de
Tue Dec 6 16:29:33 EST 2011


Be more semantically accurate and avoid accidental overwriting of some
configuration variables that are considered to be constant.

Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
---
 scripts/makepkg.sh.in           |    8 ++++----
 scripts/pacman-db-upgrade.sh.in |    2 +-
 scripts/pacman-key.sh.in        |    2 +-
 scripts/pacman-optimize.sh.in   |    2 +-
 scripts/pkgdelta.sh.in          |    2 +-
 scripts/repo-add.sh.in          |    4 ++--
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 0fa05dc..a0a94fe 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -37,10 +37,10 @@ export TEXTDOMAINDIR='@localedir@'
 # file -i does not work on Mac OSX unless legacy mode is set
 export COMMAND_MODE='legacy'
 
-myver='@PACKAGE_VERSION@'
-confdir='@sysconfdir@'
-BUILDSCRIPT='@BUILDSCRIPT@'
-startdir="$PWD"
+declare -r myver='@PACKAGE_VERSION@'
+declare -r confdir='@sysconfdir@'
+declare -r BUILDSCRIPT='@BUILDSCRIPT@'
+declare -r startdir="$PWD"
 
 packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx')
 other_options=('ccache' 'distcc' 'buildflags' 'makeflags')
diff --git a/scripts/pacman-db-upgrade.sh.in b/scripts/pacman-db-upgrade.sh.in
index 3e0d702..402a319 100644
--- a/scripts/pacman-db-upgrade.sh.in
+++ b/scripts/pacman-db-upgrade.sh.in
@@ -23,7 +23,7 @@
 export TEXTDOMAIN='pacman-scripts'
 export TEXTDOMAINDIR='@localedir@'
 
-myver='@PACKAGE_VERSION@'
+declare -r myver='@PACKAGE_VERSION@'
 
 eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
 dbroot="${DBPath:- at localstatedir@/lib/pacman/}"
diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in
index ee43dde..e0f48f5 100644
--- a/scripts/pacman-key.sh.in
+++ b/scripts/pacman-key.sh.in
@@ -24,7 +24,7 @@
 export TEXTDOMAIN='pacman-scripts'
 export TEXTDOMAINDIR='@localedir@'
 
-myver="@PACKAGE_VERSION@"
+declare -r myver="@PACKAGE_VERSION@"
 
 # Options
 ADD=0
diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in
index 154f982..7e9d7bb 100644
--- a/scripts/pacman-optimize.sh.in
+++ b/scripts/pacman-optimize.sh.in
@@ -24,7 +24,7 @@
 export TEXTDOMAIN='pacman-scripts'
 export TEXTDOMAINDIR='@localedir@'
 
-myver='@PACKAGE_VERSION@'
+declare -r myver='@PACKAGE_VERSION@'
 
 eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
 dbroot="${DBPath:- at localstatedir@/lib/pacman/}"
diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in
index ef34c5b..22a3cd2 100644
--- a/scripts/pkgdelta.sh.in
+++ b/scripts/pkgdelta.sh.in
@@ -26,7 +26,7 @@ set -o errexit
 export TEXTDOMAIN='pacman-scripts'
 export TEXTDOMAINDIR='@localedir@'
 
-myver='@PACKAGE_VERSION@'
+declare -r myver='@PACKAGE_VERSION@'
 
 QUIET=0
 
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 8fa3b72..bd7b8a2 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -25,8 +25,8 @@ shopt -s extglob
 export TEXTDOMAIN='pacman-scripts'
 export TEXTDOMAINDIR='@localedir@'
 
-myver='@PACKAGE_VERSION@'
-confdir='@sysconfdir@'
+declare -r myver='@PACKAGE_VERSION@'
+declare -r confdir='@sysconfdir@'
 
 QUIET=0
 DELTA=0
-- 
1.7.8



More information about the pacman-dev mailing list