[PATCH build 3/3] Use consistent parameter expansion notation.
Trevor Woerner
twoerner at gmail.com
Wed Sep 15 23:09:54 PDT 2010
From: Trevor Woerner <twoerner at gmail.com>
Wrap bash parameter names in curly braces for expansion.
Signed-off-by: Trevor Woerner <twoerner at gmail.com>
---
So far 2 people have suggested they prefer seeing bash parameters consistently
wrapped in curly braces and only 1 person has mentioned the preference to see
the braces used only when necessary.
Personally I have no preference. So I provide this patch as a corollary
to my previous "Remove superfluous braces around variables" patch. People
are welcome to comment and whichever proves to be more popular can be
applied by those with commit access.
build.sh | 228 +++++++++++++++++++++++++++++++-------------------------------
1 files changed, 114 insertions(+), 114 deletions(-)
diff --git a/build.sh b/build.sh
index 20aee43..e758373 100755
--- a/build.sh
+++ b/build.sh
@@ -10,8 +10,8 @@ global environment variables you may set:
global environment variables you may set to replace default functionality:
ACLOCAL: alternate invocation for 'aclocal' (default: aclocal)
MAKE: program to use instead of 'make' (default: make)
- FONTPATH: font path to use (defaults under: \$PREFIX/\$LIBDIR...)
- LIBDIR: path under \$PREFIX for libraries (e.g., lib64) (default: lib)
+ FONTPATH: font path to use (defaults under: \${PREFIX}/\${LIBDIR}...)
+ LIBDIR: path under \${PREFIX} for libraries (e.g., lib64) (default: lib)
GITROOT: path to freedesktop.org git root, only needed for --clone
(default: git://anongit.freedesktop.org/git)
@@ -20,12 +20,12 @@ global environment variables you may set to augment functionality:
CONFCFLAGS: additional compile flags to pass to all configure scripts
MAKEFLAGS: additional flags to pass to all make invocations
PKG_CONFIG_PATH: include paths in addition to:
- \$DESTDIR/\$PREFIX/share/pkgconfig
- \$DESTDIR/\$PREFIX/\$LIBDIR/pkgconfig
+ \${DESTDIR}/\${PREFIX}/share/pkgconfig
+ \${DESTDIR}/\${PREFIX}/\${LIBDIR}/pkgconfig
LD_LIBRARY_PATH: include paths in addition to:
- \$DESTDIR/\$PREFIX/\$LIBDIR
+ \${DESTDIR}/\${PREFIX}/\${LIBDIR}
PATH: include paths in addition to:
- \$DESTDIR/\$PREFIX/bin
+ \${DESTDIR}/\${PREFIX}/bin
EOF
}
@@ -37,31 +37,31 @@ setup_buildenv() {
# Must create local aclocal dir or aclocal fails
ACLOCAL_LOCALDIR="${DESTDIR}${PREFIX}/share/aclocal"
- $SUDO mkdir -p ${ACLOCAL_LOCALDIR}
+ ${SUDO} mkdir -p ${ACLOCAL_LOCALDIR}
# The following is required to make aclocal find our .m4 macros
ACLOCAL=${ACLOCAL:="aclocal"}
export ACLOCAL="${ACLOCAL} -I ${ACLOCAL_LOCALDIR}"
# The following is required to make pkg-config find our .pc metadata files
- export PKG_CONFIG_PATH=${DESTDIR}${PREFIX}/share/pkgconfig:${DESTDIR}${PREFIX}/${LIBDIR}/pkgconfig${PKG_CONFIG_PATH+:$PKG_CONFIG_PATH}
+ export PKG_CONFIG_PATH=${DESTDIR}${PREFIX}/share/pkgconfig:${DESTDIR}${PREFIX}/${LIBDIR}/pkgconfig${PKG_CONFIG_PATH+:${PKG_CONFIG_PATH}}
# Set the library path so that locally built libs will be found by apps
- export LD_LIBRARY_PATH=${DESTDIR}${PREFIX}/${LIBDIR}${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}
+ export LD_LIBRARY_PATH=${DESTDIR}${PREFIX}/${LIBDIR}${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}
# Set the path so that locally built apps will be found and used
- export PATH=${DESTDIR}${PREFIX}/bin${PATH+:$PATH}
+ export PATH=${DESTDIR}${PREFIX}/bin${PATH+:${PATH}}
# Choose which make program to use
MAKE=${MAKE:="make"}
# Set the default font path for xserver/xorg unless it's already set
- if [ -z "$FONTPATH" ]; then
+ if [ -z "${FONTPATH}" ]; then
export FONTPATH="${PREFIX}/${LIBDIR}/X11/fonts/misc/,${PREFIX}/${LIBDIR}/X11/fonts/Type1/,${PREFIX}/${LIBDIR}/X11/fonts/75dpi/,${PREFIX}/${LIBDIR}/X11/fonts/100dpi/,${PREFIX}/${LIBDIR}/X11/fonts/cyrillic/,${PREFIX}/${LIBDIR}/X11/fonts/TTF/"
fi
# Create the log file directory
- $SUDO mkdir -p ${DESTDIR}${PREFIX}/var/log
+ ${SUDO} mkdir -p ${DESTDIR}${PREFIX}/var/log
}
failed_components=""
@@ -70,30 +70,30 @@ clonefailed_components=""
failed() {
if [ -n "${NOQUIT}" ]; then
- echo "***** $1 failed on $2/$3"
- failed_components="$failed_components $2/$3"
+ echo "***** ${1} failed on ${2}/${3}"
+ failed_components="${failed_components} ${2}/${3}"
else
exit 1
fi
}
checkfortars() {
- M=$1
- C=$2
- case $M in
+ M=${1}
+ C=${2}
+ case ${M} in
"data")
- case $C in
+ case ${C} in
"cursors") C="xcursor-themes" ;;
"bitmaps") C="xbitmaps" ;;
esac
;;
"font")
- if [ "$C" != "encodings" ]; then
- C="font-$C"
+ if [ "${C}" != "encodings" ]; then
+ C="font-${C}"
fi
;;
"lib")
- case $C in
+ case ${C} in
"libXRes") C="libXres" ;;
"libxtrans") C="xtrans" ;;
esac
@@ -103,18 +103,18 @@ checkfortars() {
C="pixman"
;;
"proto")
- case $C in
+ case ${C} in
"x11proto") C="xproto" ;;
esac
;;
"util")
- case $C in
+ case ${C} in
"cf") C="xorg-cf-files" ;;
"macros") C="util-macros" ;;
esac
;;
"xcb")
- case $C in
+ case ${C} in
"proto") C="xcb-proto" ;;
"pthread-stubs") M="lib"; C="libpthread-stubs" ;;
"util") C="xcb-util" ;;
@@ -124,17 +124,17 @@ checkfortars() {
C="xorg-server"
;;
esac
- for ii in $M .; do
+ for ii in ${M} .; do
for jj in bz2 gz; do
- TARFILE=`ls -1rt $ii/$C-*.tar.$jj 2> /dev/null | tail -n 1`
- if [ -n "$TARFILE" ]; then
- SRCDIR=`echo $TARFILE | sed "s,.tar.$jj,,"`
- if [ ! -d $SRCDIR ]; then
+ TARFILE=`ls -1rt ${ii}/${C}-*.tar.${jj} 2> /dev/null | tail -n 1`
+ if [ -n "${TARFILE}" ]; then
+ SRCDIR=`echo ${TARFILE} | sed "s,.tar.${jj},,"`
+ if [ ! -d ${SRCDIR} ]; then
TAROPTS=xjf
- if [ "$jj" = "gz" ]; then
+ if [ "${jj}" = "gz" ]; then
TAROPTS=xzf
fi
- tar $TAROPTS $TARFILE -C $ii || failed tar $1 $2
+ tar ${TAROPTS} ${TARFILE} -C ${ii} || failed tar ${1} ${2}
fi
return
fi
@@ -143,7 +143,7 @@ checkfortars() {
}
clone() {
- case $1 in
+ case ${1} in
"pixman")
BASEDIR=""
;;
@@ -161,12 +161,12 @@ clone() {
;;
esac
- DIR="$1/$2"
+ DIR="${1}/${2}"
GITROOT=${GITROOT:="git://anongit.freedesktop.org/git"}
- if [ ! -d "$DIR" ]; then
- git clone "$GITROOT/$BASEDIR$DIR" "$DIR"
- if [ $? -ne 0 ] && [ ! -d "$DIR" ]; then
+ if [ ! -d "${DIR}" ]; then
+ git clone "${GITROOT}/${BASEDIR}${DIR}" "${DIR}"
+ if [ ${?} -ne 0 ] && [ ! -d "${DIR}" ]; then
return 1
fi
else
@@ -178,67 +178,67 @@ clone() {
}
build() {
- if [ -n "$LISTONLY" ]; then
- echo "$1/$2"
+ if [ -n "${LISTONLY}" ]; then
+ echo "${1}/${2}"
return 0
fi
- if [ -n "$RESUME" ]; then
- if [ "$RESUME" = "$1/$2" ]; then
+ if [ -n "${RESUME}" ]; then
+ if [ "${RESUME}" = "${1}/${2}" ]; then
unset RESUME
# Resume build at this module
else
- echo "Skipping $1 module component $2..."
+ echo "Skipping ${1} module component ${2}..."
return 0
fi
fi
SRCDIR=""
CONFCMD=""
- if [ -f $1/$2/autogen.sh ]; then
- SRCDIR="$1/$2"
+ if [ -f ${1}/${2}/autogen.sh ]; then
+ SRCDIR="${1}/${2}"
CONFCMD="autogen.sh"
- elif [ -n "$CLONE" ]; then
- clone $1 $2
- if [ $? -ne 0 ]; then
- echo "Failed to clone $1 module component $2. Ignoring."
- clonefailed_components="$clonefailed_components $1/$2"
- if [ -n "$BUILD_ONE" ]; then
+ elif [ -n "${CLONE}" ]; then
+ clone ${1} ${2}
+ if [ ${?} -ne 0 ]; then
+ echo "Failed to clone ${1} module component ${2}. Ignoring."
+ clonefailed_components="${clonefailed_components} ${1}/${2}"
+ if [ -n "${BUILD_ONE}" ]; then
exit 1
fi
return
fi
- SRCDIR="$1/$2"
+ SRCDIR="${1}/${2}"
CONFCMD="autogen.sh"
else
- checkfortars $1 $2
+ checkfortars ${1} ${2}
CONFCMD="configure"
fi
- if [ -z "$SRCDIR" ]; then
- echo "$1 module component $2 does not exist, skipping."
- nonexistent_components="$nonexistent_components $1/$2"
+ if [ -z "${SRCDIR}" ]; then
+ echo "${1} module component ${2} does not exist, skipping."
+ nonexistent_components="${nonexistent_components} ${1}/${2}"
return
fi
- echo "Building $1 module component $2..."
+ echo "Building ${1} module component ${2}..."
- if [ -n "$BUILT_MODULES_FILE" ]; then
- echo "$1/$2" >> $BUILT_MODULES_FILE
+ if [ -n "${BUILT_MODULES_FILE}" ]; then
+ echo "${1}/${2}" >> ${BUILT_MODULES_FILE}
fi
old_pwd=`pwd`
- cd $SRCDIR || failed cd1 $1 $2
+ cd ${SRCDIR} || failed cd1 ${1} ${2}
- if [ -n "$PULL" ]; then
- git pull --rebase || failed "git pull" $1 $2
+ if [ -n "${PULL}" ]; then
+ git pull --rebase || failed "git pull" ${1} ${2}
fi
# Build outside source directory
- if [ -n "$DIR_ARCH" ] ; then
- mkdir -p "$DIR_ARCH" || failed mkdir $1 $2
- if cd "$DIR_ARCH" ; then :; else
- failed cd2 $1 $2
+ if [ -n "${DIR_ARCH}" ] ; then
+ mkdir -p "${DIR_ARCH}" || failed mkdir ${1} ${2}
+ if cd "${DIR_ARCH}" ; then :; else
+ failed cd2 ${1} ${2}
cd ${old_pwd}
return
fi
@@ -247,41 +247,41 @@ build() {
# Special configure flags for certain modules
MOD_SPECIFIC=
- if [ "$1" = "lib" ] && [ "$2" = "libX11" ] && [ "${USE_XCB}" = "NO" ]; then
+ if [ "${1}" = "lib" ] && [ "${2}" = "libX11" ] && [ "${USE_XCB}" = "NO" ]; then
MOD_SPECIFIC="--with-xcb=no"
fi
LIB_FLAGS=
- if [ -n "$LIBDIR" ]; then
+ if [ -n "${LIBDIR}" ]; then
LIB_FLAGS="--libdir=${PREFIX}/${LIBDIR}"
fi
# Use "sh autogen.sh" since some scripts are not executable in CVS
- if [ -z "$NOAUTOGEN" ]; then
+ if [ -z "${NOAUTOGEN}" ]; then
sh ${DIR_CONFIG}/${CONFCMD} --prefix=${PREFIX} ${LIB_FLAGS} \
${MOD_SPECIFIC} ${QUIET:+--quiet} \
- ${CACHE:+--cache-file=}${CACHE} ${CONFFLAGS} "$CONFCFLAGS" || \
- failed ${CONFCMD} $1 $2
+ ${CACHE:+--cache-file=}${CACHE} ${CONFFLAGS} "${CONFCFLAGS}" || \
+ failed ${CONFCMD} ${1} ${2}
fi
- ${MAKE} $MAKEFLAGS || failed make $1 $2
- if [ -n "$CHECK" ]; then
- ${MAKE} $MAKEFLAGS check || failed check $1 $2
+ ${MAKE} ${MAKEFLAGS} || failed make ${1} ${2}
+ if [ -n "${CHECK}" ]; then
+ ${MAKE} ${MAKEFLAGS} check || failed check ${1} ${2}
fi
- if [ -n "$CLEAN" ]; then
- ${MAKE} $MAKEFLAGS clean || failed clean $1 $2
+ if [ -n "${CLEAN}" ]; then
+ ${MAKE} ${MAKEFLAGS} clean || failed clean ${1} ${2}
fi
- if [ -n "$DIST" ]; then
- ${MAKE} $MAKEFLAGS dist || failed dist $1 $2
+ if [ -n "${DIST}" ]; then
+ ${MAKE} ${MAKEFLAGS} dist || failed dist ${1} ${2}
fi
- if [ -n "$DISTCHECK" ]; then
- ${MAKE} $MAKEFLAGS distcheck || failed distcheck $1 $2
+ if [ -n "${DISTCHECK}" ]; then
+ ${MAKE} ${MAKEFLAGS} distcheck || failed distcheck ${1} ${2}
fi
- $SUDO env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ${MAKE} $MAKEFLAGS install || \
- failed install $1 $2
+ ${SUDO} env LD_LIBRARY_PATH=${LD_LIBRARY_PATH} ${MAKE} ${MAKEFLAGS} install || \
+ failed install ${1} ${2}
cd ${old_pwd}
- if [ -n "$BUILD_ONE" ]; then
+ if [ -n "${BUILD_ONE}" ]; then
echo "Single-component build complete"
exit 0
fi
@@ -289,7 +289,7 @@ build() {
# protocol headers have no build order dependencies
build_proto() {
- case $HOST_OS in
+ case ${HOST_OS} in
Darwin*)
build proto applewmproto
;;
@@ -364,7 +364,7 @@ build_lib() {
fi
build lib libX11
build lib libXext
- case $HOST_OS in
+ case ${HOST_OS} in
Darwin*)
build lib libAppleWM
;;
@@ -516,7 +516,7 @@ build_xserver() {
build_driver_input() {
# Some drivers are only buildable on some OS'es
- case $HOST_OS in
+ case ${HOST_OS} in
Linux)
build driver xf86-input-aiptek
build driver xf86-input-evdev
@@ -530,7 +530,7 @@ build_driver_input() {
esac
# And some drivers are only buildable on some CPUs.
- case $HOST_CPU in
+ case ${HOST_CPU} in
i*86* | amd64* | x86*64*)
build driver xf86-input-vmmouse
;;
@@ -548,9 +548,9 @@ build_driver_input() {
build_driver_video() {
# Some drivers are only buildable on some OS'es
- case $HOST_OS in
+ case ${HOST_OS} in
*FreeBSD*)
- case $HOST_CPU in
+ case ${HOST_CPU} in
sparc64)
build driver xf86-video-sunffb
;;
@@ -573,7 +573,7 @@ build_driver_video() {
esac
# Some drivers are only buildable on some architectures
- case $HOST_CPU in
+ case ${HOST_CPU} in
*sparc*)
build driver xf86-video-suncg14
build driver xf86-video-suncg3
@@ -590,7 +590,7 @@ build_driver_video() {
esac
# Some drivers are only buildable on some architectures of some OS's
- case "$HOST_CPU"-"$HOST_OS" in
+ case "${HOST_CPU}"-"${HOST_OS}" in
i*86*-*Linux*)
build driver xf86-video-geode
;;
@@ -636,7 +636,7 @@ build_driver_video() {
# The server must be built before the drivers
build_driver() {
# XQuartz doesn't need these...
- case $HOST_OS in
+ case ${HOST_OS} in
Darwin*) return 0 ;;
esac
@@ -720,10 +720,10 @@ build_doc() {
}
usage() {
- echo "Usage: $0 [options] prefix"
+ echo "Usage: ${0} [options] prefix"
echo " where options are:"
echo " -a : do NOT run auto config tools (autogen.sh, configure)"
- echo " -b : use .build.$HAVE_ARCH build directory"
+ echo " -b : use .build.${HAVE_ARCH} build directory"
echo " -c : run make clean in addition to others"
echo " -d : run make distcheck in addition to others"
echo " -D : run make dist in addition to others"
@@ -741,7 +741,7 @@ usage() {
echo " --autoresume file : autoresume from file"
echo " --check : run make check in addition to others"
echo ""
- echo "Usage: $0 -L"
+ echo "Usage: ${0} -L"
echo " -L : just list modules to build"
echo ""
envoptions
@@ -753,14 +753,14 @@ DIR_CONFIG="."
LIB_ONLY=0
# Process command line args
-while [ $# != 0 ]
+while [ ${#} != 0 ]
do
- case $1 in
+ case ${1} in
-a)
NOAUTOGEN=1
;;
-b)
- DIR_ARCH=".build.$HAVE_ARCH"
+ DIR_ARCH=".build.${HAVE_ARCH}"
DIR_CONFIG=".."
;;
-c)
@@ -780,7 +780,7 @@ do
;;
-f)
shift
- BUILT_MODULES_FILE=$1
+ BUILT_MODULES_FILE=${1}
;;
-g)
CFLAGS="-g3 -O0"
@@ -799,7 +799,7 @@ do
;;
-o)
shift
- RESUME=$1
+ RESUME=${1}
BUILD_ONE=1
;;
-p)
@@ -807,36 +807,36 @@ do
;;
-r)
shift
- RESUME=$1
+ RESUME=${1}
;;
--autoresume)
shift
- BUILT_MODULES_FILE=$1
- [ -f $1 ] && RESUME=`tail -n 1 $1`
+ BUILT_MODULES_FILE=${1}
+ [ -f ${1} ] && RESUME=`tail -n 1 ${1}`
;;
-s)
shift
- SUDO=$1
+ SUDO=${1}
;;
-L)
LISTONLY=1
;;
*)
- PREFIX=$1
+ PREFIX=${1}
;;
esac
shift
done
-if [ -z "${PREFIX}" ] && [ -z "$LISTONLY" ]; then
+if [ -z "${PREFIX}" ] && [ -z "${LISTONLY}" ]; then
usage
exit
fi
-if [ -z "$LISTONLY" ]; then
+if [ -z "${LISTONLY}" ]; then
setup_buildenv
- echo "Building to run $HOST_OS / $HOST_CPU ($HOST)"
+ echo "Building to run ${HOST_OS} / ${HOST_CPU} (${HOST})"
date
fi
@@ -848,7 +848,7 @@ build_proto
build_lib
build_mesa
-if [ $LIB_ONLY -eq 0 ]; then
+if [ ${LIB_ONLY} -eq 0 ]; then
build_doc
build data bitmaps
build_app
@@ -859,30 +859,30 @@ if [ $LIB_ONLY -eq 0 ]; then
build_util
fi
-if [ -n "$LISTONLY" ]; then
+if [ -n "${LISTONLY}" ]; then
exit 0
fi
date
-if [ -n "$nonexistent_components" ]; then
+if [ -n "${nonexistent_components}" ]; then
echo ""
echo "***** Skipped components (not available) *****"
- echo "$nonexistent_components"
+ echo "${nonexistent_components}"
echo ""
fi
-if [ -n "$failed_components" ]; then
+if [ -n "${failed_components}" ]; then
echo ""
echo "***** Failed components *****"
- echo "$failed_components"
+ echo "${failed_components}"
echo ""
fi
-if [ -n "$CLONE" ] && [ -n "$clonefailed_components" ]; then
+if [ -n "${CLONE}" ] && [ -n "${clonefailed_components}" ]; then
echo ""
echo "***** Components failed to clone *****"
- echo "$clonefailed_components"
+ echo "${clonefailed_components}"
echo ""
fi
--
1.7.3.rc1.4.g5879b6
More information about the xorg-devel
mailing list