Commit 56d4dec1 authored by Lukas Fleischer's avatar Lukas Fleischer Committed by Pierre Schmitz
Browse files

Use double brackets everywhere



We already fixed a couple of these in previous patches - this one should
replace all remaining uses of single brackets ("[") by double brackets.
Also, use arithmetic evaluation instead of conditional expressions where
appropriate and make use of "-z" and "-n" instead of comparing variables
to empty strings.

Signed-off-by: default avatarLukas Fleischer <archlinux@cryptocrack.de>
parent f62f307c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ m4_include(lib/common.sh)

scriptname=${0##*/}

if [ "$1" = '' ]; then
if [[ -z $1 ]]; then
	echo 'Usage: '$scriptname' <package name>...'
	exit 1
fi
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

m4_include(lib/common.sh)

if [ "$1" = '' ]; then
if [[ -z $1 ]]; then
	echo 'Usage: archrm <path to checkout>'
	exit 1
fi
+19 −19
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ m4_include(lib/common.sh)
getpkgfile() {
	if [[ ${#} -ne 1 ]]; then
		die 'No canonical package found!'
	elif [ ! -f "${1}" ]; then
	elif [[ ! -f $1 ]]; then
		die "Package ${1} not found!"
	fi

@@ -13,20 +13,20 @@ getpkgfile() {
}

# Source makepkg.conf; fail if it is not found
if [ -r '/etc/makepkg.conf' ]; then
if [[ -r '/etc/makepkg.conf' ]]; then
	source '/etc/makepkg.conf'
else
	die '/etc/makepkg.conf not found!'
fi

# Source user-specific makepkg.conf overrides
if [ -r ~/.makepkg.conf ]; then
if [[ -r ~/.makepkg.conf ]]; then
	. ~/.makepkg.conf
fi

cmd=${0##*/}

if [ ! -f PKGBUILD ]; then
if [[ ! -f PKGBUILD ]]; then
	die 'No PKGBUILD file'
fi

@@ -35,7 +35,7 @@ pkgbase=${pkgbase:-$pkgname}

case "$cmd" in
	commitpkg)
		if [ $# -eq 0 ]; then
		if (( $# == 0 )); then
			die 'usage: commitpkg <reponame> [-l limit] [-a arch] [commit message]'
		fi
		repo="$1"
@@ -89,25 +89,25 @@ while getopts ':l:a:' flag; do
done
shift $(( OPTIND - 1 ))

if [ -n "$(svn status -q)" ]; then
if [[ -n $(svn status -q) ]]; then
	msgtemplate="upgpkg: $pkgbase $(get_full_version)"$'\n\n'
	if [ -n "$1" ]; then
	if [[ -n $1 ]]; then
		stat_busy 'Committing changes to trunk'
		svn commit -q -m "${msgtemplate}${1}" || die
		stat_done
	else
		msgfile="$(mktemp)"
		echo "$msgtemplate" > "$msgfile"
		if [ -n "$SVN_EDITOR" ]; then
		if [[ -n $SVN_EDITOR ]]; then
			$SVN_EDITOR "$msgfile"
		elif [ -n "$VISUAL" ]; then
		elif [[ -n $VISUAL ]]; then
			$VISUAL "$msgfile"
		elif [ -n "$EDITOR" ]; then
		elif [[ -n $EDITOR ]]; then
			$EDITOR "$msgfile"
		else
			vi "$msgfile"
		fi
		[ -s "$msgfile" ] || die
		[[ -s $msgfile ]] || die
		stat_busy 'Committing changes to trunk'
		svn commit -q -F "$msgfile" || die
		unlink "$msgfile"
@@ -120,7 +120,7 @@ declare -a commit_arches
declare -a skip_arches

for _arch in ${arch[@]}; do
	if [ -n "$commit_arch" ] && [ "${_arch}" != "$commit_arch" ]; then
	if [[ -n $commit_arch && ${_arch} != "$commit_arch" ]]; then
		skip_arches+=($_arch)
		continue
	fi
@@ -130,9 +130,9 @@ for _arch in ${arch[@]}; do
		pkgfile=$(getpkgfile "$_pkgname-$fullver-${_arch}".pkg.tar.?z 2>/dev/null)
		pkgdestfile=$(getpkgfile "$PKGDEST/$_pkgname-$fullver-${_arch}".pkg.tar.?z 2>/dev/null)

		if [ -f "$pkgfile" ]; then
		if [[ -f $pkgfile ]]; then
			pkgfile="./$pkgfile"
		elif [ -f "$pkgdestfile" ]; then
		elif [[ -f $pkgdestfile ]]; then
			pkgfile="$pkgdestfile"
		else
			warning "Could not find ${pkgfile}. Skipping ${_arch}"
@@ -142,14 +142,14 @@ for _arch in ${arch[@]}; do
		uploads+=("$pkgfile")

		sigfile="${pkgfile}.sig"
		if [[ $SIGNPKG == 'y' ]] && [ ! -f "${sigfile}" ]; then
		if [[ $SIGNPKG == 'y' && ! -f $sigfile ]]; then
			msg "Signing package ${pkgfile}..."
			if [[ -n $GPGKEY ]]; then
				SIGNWITHKEY="-u ${GPGKEY}"
			fi
			gpg --detach-sign --use-agent ${SIGNWITHKEY} "${pkgfile}" || die
		fi
		if [ -f "${sigfile}" ]; then
		if [[ -f $sigfile ]]; then
			if ! gpg --verify "$sigfile" >/dev/null 2>&1; then
				die "Signature ${pkgfile}.sig is incorrect!"
			fi
@@ -172,8 +172,8 @@ if [[ ${#uploads[*]} -gt 0 ]]; then
	rsync "${rsyncopts[@]}" "${uploads[@]}" "$server:staging/$repo/" || die
fi

if [ "${arch[*]}" == 'any' ]; then
	if [ -d ../repos/$repo-i686 -a -d ../repos/$repo-x86_64 ]; then
if [[ "${arch[*]}" == 'any' ]]; then
	if [[ -d ../repos/$repo-i686 && -d ../repos/$repo-x86_64 ]]; then
		pushd ../repos/ >/dev/null
		stat_busy "Removing $repo-i686 and $repo-x86_64"
		svn rm -q $repo-i686
@@ -183,7 +183,7 @@ if [ "${arch[*]}" == 'any' ]; then
		popd >/dev/null
	fi
else
	if [ -d ../repos/$repo-any ]; then
	if [[ -d ../repos/$repo-any ]]; then
		pushd ../repos/ >/dev/null
		stat_busy "Removing $repo-any"
		svn rm -q $repo-any
+2 −2
Original line number Diff line number Diff line
@@ -68,12 +68,12 @@ find . -type f $find_args | while read filename; do

	# get architecture of the file; if soarch is empty it's not an ELF binary
	soarch=$(LC_ALL=C readelf -h "$filename" 2>/dev/null | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
	[ -n "$soarch" ] || continue
	[[ -n $soarch ]] || continue

	if [[ $script_mode = "provides" ]]; then
		# get the string binaries link to: libfoo.so.1.2 -> libfoo.so.1
		sofile=$(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
		[ -z "$sofile" ] && sofile="${filename##*/}"
		[[ -z $sofile" ]] && sofile="${filename##*/}"
		process_sofile
	elif [[ $script_mode = "deps" ]]; then
		# process all libraries needed by the binary
+2 −2
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@ for tree in $PATH $libdirs $extras; do
	-name '*.mcopclass' ! -name '*.mcoptype')
	IFS=$ifs
	for i in $files; do
		if [ $(file $i | grep -c 'ELF') -ne 0 ]; then
		if (( $(file $i | grep -c 'ELF') != 0 )); then
			#  Is an ELF binary.
			if [ $(ldd $i 2>/dev/null | grep -c 'not found') -ne 0 ]; then
			if (( $(ldd $i 2>/dev/null | grep -c 'not found') != 0 )); then
				#  Missing lib.
				echo "$i:" >> $TEMPDIR/raw.txt
				ldd $i 2>/dev/null | grep 'not found' >> $TEMPDIR/raw.txt
Loading