[PC-BSD Commits] r15473 - pcbsd/current/src-sh/pbi-manager

svn at pcbsd.org svn at pcbsd.org
Fri Feb 17 10:51:11 PST 2012


Author: kris
Date: 2012-02-17 18:51:10 +0000 (Fri, 17 Feb 2012)
New Revision: 15473

Modified:
   pcbsd/current/src-sh/pbi-manager/pbi-manager
Log:

Add patch from Baptiste Daroussin, and simplify some other conditionals



Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager	2012-02-17 18:29:54 UTC (rev 15472)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager	2012-02-17 18:51:10 UTC (rev 15473)
@@ -626,7 +626,7 @@
 		     if [ ! -f "${PBI_IT_ADDINDEX}" ] ; then 
 			exit_err "No such file ${PBI_IT_ADDINDEX}"
 		     fi
-		     if [ ! -z "${PBI_IT_ADDKEEP}" ] ; then 
+		     if [ -n "${PBI_IT_ADDKEEP}" ] ; then 
 			expr ${PBI_IT_ADDKEEP} + 1 >/dev/null 2>/dev/null
 			if [ "$?" != "0" ] ; then
 				exit_err "-k option must be a integer!"
@@ -662,7 +662,7 @@
         done
 
 	# Get / check the repoid
-	if [ ! -z "${PBI_BROWSE_RID}" ] ; then
+	if [ -n "${PBI_BROWSE_RID}" ] ; then
 		ls ${PBI_DBREPODIR}/${PBI_BROWSE_RID}.* >/dev/null 2>/dev/null
 		if [ "$?" != "0" ] ; then
 			exit_err "The specified repoid ${PBI_BROWSE_RID} does not exist!"
@@ -709,11 +709,11 @@
 	if [ "${PBI_LISTREPO_DOWN}" = "YES" -a -z "${PBI_LISTREPO_ID}" ]; then
 		exit_err "Missing Repo ID to move down in priority."
 	fi
-	if [ ! -z "${PBI_LISTREPO_MIRROR}" -a -z "${PBI_LISTREPO_ID}" ]; then
+	if [ -n "${PBI_LISTREPO_MIRROR}" -a -z "${PBI_LISTREPO_ID}" ]; then
 		exit_err "Missing Repo ID to change a specific mirror URL."
 	fi
 
-	if [ ! -z "${PBI_LISTREPO_ID}" ] ; then
+	if [ -n "${PBI_LISTREPO_ID}" ] ; then
 		ls ${PBI_DBREPODIR}/${PBI_LISTREPO_ID}.* >/dev/null 2>/dev/null
 		if [ "$?" != "0" ] ; then
 			exit_err "The specified repoid ${PBI_LISTREPO_ID} does not exist!"
@@ -847,7 +847,7 @@
                 # If extracting to a alt-outdir, set it now
                 PBI_PROGDIRPATH="`pwd`/${PBI_PROGDIRNAME}"
         
-                if [ ! -z "${PBI_ALTEXTRACT_DIR}" ]; then
+                if [ -n "${PBI_ALTEXTRACT_DIR}" ]; then
                         PBI_PROGDIRPATH="${PBI_ALTEXTRACT_DIR}/${PBI_PROGDIRNAME}"
                 fi      
         else
@@ -944,7 +944,7 @@
 		# If extracting to a alt-outdir, set it now
 		PBI_PROGDIRPATH="`pwd`/${PBI_PROGDIRNAME}"
 
-		if [ ! -z "${PBI_ALTEXTRACT_DIR}" ]; then
+		if [ -n "${PBI_ALTEXTRACT_DIR}" ]; then
 			PBI_PROGDIRPATH="${PBI_ALTEXTRACT_DIR}/${PBI_PROGDIRNAME}"
 		fi
 	else
@@ -958,7 +958,7 @@
         while [ $# -gt 0 ]; do
                 case "$1" in
                 -c)     if [ $# -eq 1 ]; then usage_autob_pbi; fi
-                        if [ ! -z "${PBI_AB_CONFDIR}" ]; then usage_autob_pbi; fi
+                        if [ -n "${PBI_AB_CONFDIR}" ]; then usage_autob_pbi; fi
                         shift
                         get_abspath "$1"
                         PBI_AB_CONFDIR="$_ABSPATH"
@@ -1069,12 +1069,12 @@
         done
 
 	# Make sure this port exists
-        if [ ! -z "${PBI_MAKEPORT}" -a ! -d "${PORTSDIR}/${PBI_MAKEPORT}" ]; then
+        if [ -n "${PBI_MAKEPORT}" -a ! -d "${PORTSDIR}/${PBI_MAKEPORT}" ]; then
 		exit_err "No port (${PORTSDIR}/${PBI_MAKEPORT})"
 	fi
 
 	# Load the name / version from specified port
-        if [ ! -z "${PBI_MAKEPORT}" ]; then
+        if [ -n "${PBI_MAKEPORT}" ]; then
 		get_pbi_progversion
 		get_pbi_progname
         fi
@@ -1087,11 +1087,11 @@
 
 # Override any pbi.conf values with passed command-line values
 parse_cmdline_overrides() {
-	if [ ! -z "${PBI_CNAME}" ] ; then PBI_PROGNAME="${PBI_CNAME}" ; fi
-	if [ ! -z "${PBI_CVERSION}" ] ; then PBI_PROGVERSION="${PBI_CVERSION}" ; fi
-	if [ ! -z "${PBI_CWEB}" ] ; then PBI_PROGWEB="${PBI_CWEB}" ; fi
-	if [ ! -z "${PBI_CAUTHOR}" ] ; then PBI_PROGAUTHOR="${PBI_CAUTHOR}" ; fi
-	if [ ! -z "${PBI_CICON}" ] ; then PBI_PROGICON="${PBI_CICON}" ; fi
+	if [ -n "${PBI_CNAME}" ] ; then PBI_PROGNAME="${PBI_CNAME}" ; fi
+	if [ -n "${PBI_CVERSION}" ] ; then PBI_PROGVERSION="${PBI_CVERSION}" ; fi
+	if [ -n "${PBI_CWEB}" ] ; then PBI_PROGWEB="${PBI_CWEB}" ; fi
+	if [ -n "${PBI_CAUTHOR}" ] ; then PBI_PROGAUTHOR="${PBI_CAUTHOR}" ; fi
+	if [ -n "${PBI_CICON}" ] ; then PBI_PROGICON="${PBI_CICON}" ; fi
 }
 
 # Parse the command line
@@ -1102,7 +1102,7 @@
                         ;;
                 -c)
                         if [ $# -eq 1 ]; then usage_make_pbi; fi
-                        if [ ! -z "${PBI_CONFDIR}" ]; then usage_make_pbi; fi
+                        if [ -n "${PBI_CONFDIR}" ]; then usage_make_pbi; fi
                         shift
 			get_abspath "$1"
 			PBI_CONFDIR="$_ABSPATH"
@@ -1129,7 +1129,7 @@
 			PBI_CREATE_OUTDIR="$_ABSPATH"
                         ;;
                 -p)	if [ $# -eq 1 ]; then usage_make_pbi; fi
-                        if [ ! -z "${PBI_MAKEPREFIX}" ]; then usage_make_pbi; fi
+                        if [ -n "${PBI_MAKEPREFIX}" ]; then usage_make_pbi; fi
                         shift; PBI_MAKEPREFIX="$1"
                         ;;
             --sign)	if [ $# -eq 1 ]; then usage_create_pbi; fi
@@ -1147,10 +1147,10 @@
 
 	# Override some locations if working in chroot environment
 	if [ "`basename $0`" = "pbi_makeport_chroot" ] ; then 
-		if [ ! -z "${PBI_CONFDIR}" ] ; then PBI_CONFDIR="/pbimodule" ; fi
-		if [ ! -z "${PBI_SSLPRIVKEY}" ] ; then PBI_SSLPRIVKEY="/privkey.pem" ; fi
-		if [ ! -z "${PBI_CREATE_OUTDIR}" ] ; then PBI_CREATE_OUTDIR="/pbiout" ; fi
-		if [ ! -z "${PORTSDIR}" ] ; then PORTSDIR="/usr/ports" ; fi
+		if [ -n "${PBI_CONFDIR}" ] ; then PBI_CONFDIR="/pbimodule" ; fi
+		if [ -n "${PBI_SSLPRIVKEY}" ] ; then PBI_SSLPRIVKEY="/privkey.pem" ; fi
+		if [ -n "${PBI_CREATE_OUTDIR}" ] ; then PBI_CREATE_OUTDIR="/pbiout" ; fi
+		if [ -n "${PORTSDIR}" ] ; then PORTSDIR="/usr/ports" ; fi
 	fi
 
 	# Make sure this port exists
@@ -1159,12 +1159,12 @@
 	fi
 
 	# Make sure we have a valid PBI_CONFDIR
-	if [ ! -z "${PBI_CONFDIR}" -a ! -d "${PBI_CONFDIR}" ] ; then
+	if [ -n "${PBI_CONFDIR}" -a ! -d "${PBI_CONFDIR}" ] ; then
 		exit_err "Invalid confdir (${PBI_CONFDIR})"
 	fi
 
 	# Source the config file
-	if [ ! -z "${PBI_CONFDIR}" ]; then load_pbi_conffile ; fi
+	if [ -n "${PBI_CONFDIR}" ]; then load_pbi_conffile ; fi
 
         if [ -z "${PBI_MAKEPORT}" ]; then
                 usage_make_pbi
@@ -1181,7 +1181,7 @@
      --enable-auto)	PBI_UPENABLEAUTO="YES" ;; 
       --update-all)	PBI_UPDATEAPP="ALL" ;; 
                  *)     if [ $# -gt 1 ]; then usage_update_pbi; fi
-			if [ ! -z "$PBI_UPDATEAPP" ] ; then usage_update_pbi ; fi
+			if [ -n "$PBI_UPDATEAPP" ] ; then usage_update_pbi ; fi
 			if [ ! -e "${PBI_DBAPPDIR}/${1}" ] ; then
                                 exit_err "can't find installed pbi (${1})"
                         fi
@@ -1191,15 +1191,15 @@
                 shift
         done
 
-	if [ "${PBI_UPDATEAPP}" = "ALL" -a ! -z "${PBI_UPCHECK}" ] ; then
+	if [ "${PBI_UPDATEAPP}" = "ALL" -a -n "${PBI_UPCHECK}" ] ; then
                 usage_update_pbi
         fi
 
 	# Make sure we aren't trying to enable auto-updating for ALL
-	if [ "${PBI_UPDATEAPP}" = "ALL" -a ! -z "${PBI_UPENABLEAUTO}" ] ; then
+	if [ "${PBI_UPDATEAPP}" = "ALL" -a -n "${PBI_UPENABLEAUTO}" ] ; then
                 usage_update_pbi
         fi
-	if [ -z "${PBI_UPDATEAPP}" -a ! -z "${PBI_UPENABLEAUTO}" ] ; then
+	if [ -z "${PBI_UPDATEAPP}" -a -n "${PBI_UPENABLEAUTO}" ] ; then
                 usage_update_pbi
         fi
 
@@ -1461,18 +1461,18 @@
 		load_pbi_conffile
 
 		# If we have PBI_PROGVERSION now set
-		if [ ! -z "${PBI_PROGVERSION}" ] ; then return 0 ; fi
+		if [ -n "${PBI_PROGVERSION}" ] ; then return 0 ; fi
 	else
 		return 0
 	fi
 
-	if [ -z "${PBI_PROGVERSION}" -a ! -z "${PORTSDIR}" -a ! -z "${PBI_MAKEPORT}" ] ; then
+	if [ -z "${PBI_PROGVERSION}" -a -n "${PORTSDIR}" -a -n "${PBI_MAKEPORT}" ] ; then
 		PORTVER="`make -C ${PORTSDIR}/${PBI_MAKEPORT} -V DISTVERSION 2>/dev/null`"
 
   		# Check if we have a portrevision to use in version number
   		PORTREV=""
   		PORTREV="`make -C ${PORTSDIR}/${PBI_MAKEPORT} -V PORTREVISION 2>/dev/null`"
-  		if [ ! -z "${PORTREV}" -a "${PORTREV}" != "0" ]
+  		if [ -n "${PORTREV}" -a "${PORTREV}" != "0" ]
  		then
    			PORTVER="${PORTVER}_${PORTREV}"
 		fi
@@ -1488,7 +1488,7 @@
 	fi
 
 	# If we have a REVISION, use it as well
-	if [ ! -z "$PBI_PROGREVISION" ] ; then
+	if [ -n "$PBI_PROGREVISION" ] ; then
 		PBI_PROGVERSION="${PBI_PROGVERSION}_${PBI_PROGREVISION}"
 	fi
 }
@@ -1502,7 +1502,7 @@
 		return 0
 	fi
 
-	if [ -z "${PBI_PROGNAME}" -a ! -z "${PORTSDIR}" -a ! -z "${PBI_MAKEPORT}" ] ; then
+	if [ -z "${PBI_PROGNAME}" -a -n "${PORTSDIR}" -a -n "${PBI_MAKEPORT}" ] ; then
 		PBI_PROGNAME="`make -C ${PORTSDIR}/${PBI_MAKEPORT} -V PORTNAME`"
 	else
 		exit_err "Failed to locate PBI_PROGNAME"
@@ -1544,17 +1544,17 @@
 		echo "Cleaning up patch data..."
 	fi
 
-	if [ ! -z "${_pbiNewDir}" -a -d "${_pbiNewDir}" -a "${_pbiNewDir}" != "/" ] ; then
+	if [ -n "${_pbiNewDir}" -a -d "${_pbiNewDir}" -a "${_pbiNewDir}" != "/" ] ; then
 	 	rm -rf "${_pbiNewDir}" >/dev/null 2>/dev/null
 	 	chflags -R noschg "${_pbiNewDir}" >/dev/null 2>/dev/null
 	 	rm -rf "${_pbiNewDir}" >/dev/null 2>/dev/null
 	fi
-	if [ ! -z "${_pbiOldDir}" -a -d "${_pbiOldDir}" -a "${_pbiOldDir}" != "/" ] ; then
+	if [ -n "${_pbiOldDir}" -a -d "${_pbiOldDir}" -a "${_pbiOldDir}" != "/" ] ; then
 	 	rm -rf "${_pbiOldDir}" >/dev/null 2>/dev/null
 	 	chflags -R noschg "${_pbiOldDir}" >/dev/null 2>/dev/null
 	 	rm -rf "${_pbiOldDir}" >/dev/null 2>/dev/null
 	fi
-	if [ ! -z "${_pbiPatchDir}" -a -d "${_pbiPatchDir}" -a "${_pbiPatchDir}" != "/" ] ; then
+	if [ -n "${_pbiPatchDir}" -a -d "${_pbiPatchDir}" -a "${_pbiPatchDir}" != "/" ] ; then
 	 	rm -rf "${_pbiPatchDir}" >/dev/null 2>/dev/null
 	 	chflags -R noschg "${_pbiPatchDir}" >/dev/null 2>/dev/null
 	 	rm -rf "${_pbiPatchDir}" >/dev/null 2>/dev/null
@@ -1564,7 +1564,7 @@
 # Check if we need to delete a remotely dl'd file
 clean_remote_dl() {
 	# If this was a remote fetch, remove dl'd file
-	if [ "$PBI_REMOTEFETCH" = "YES" -a ! -z "$PBI_FILENAME" ]; then 
+	if [ "$PBI_REMOTEFETCH" = "YES" -a -n "$PBI_FILENAME" ]; then 
 		rm "$PBI_FILENAME" >/dev/null 2>/dev/null
 	fi
 }
@@ -1602,7 +1602,7 @@
 		echo "WRKDIRPREFIX=/usr/wrkdirprefix" >> ${MAKE_CONF}
 	fi
 
-	if [ ! -z "$PBI_MAKEOPTS" ] ; then
+	if [ -n "$PBI_MAKEOPTS" ] ; then
 		# Check if we have custom make opts
 		echo "${PBI_MAKEOPTS}" >> ${MAKE_CONF}
 	fi
@@ -2009,15 +2009,15 @@
 	_rArch=`uname -m`
 
 	# Figure out which type of display we are doing
-	if [ ! -z "$PBI_BROWSE_LISTALLPBI" ] ; then
+	if [ -n "$PBI_BROWSE_LISTALLPBI" ] ; then
 		echo "Using RepoID: $PBI_BROWSE_RID"
 		echo "Listing all available PBIs"
 		grep -i -e "^App=" $PBI_BROWSE_METAFILE > ${PBI_TMPDIR}/.meta.$$
-	elif [ ! -z "$PBI_BROWSE_CAT" ] ; then
+	elif [ -n "$PBI_BROWSE_CAT" ] ; then
 		echo "Using RepoID: $PBI_BROWSE_RID"
 		echo "Available PBIs for Category: $PBI_BROWSE_CAT"
 		grep -i -e "^App=" -i -e ";${PBI_BROWSE_CAT};" $PBI_BROWSE_METAFILE > ${PBI_TMPDIR}/.meta.$$
-	elif [ ! -z "$PBI_BROWSE_SEARCH" ] ; then
+	elif [ -n "$PBI_BROWSE_SEARCH" ] ; then
 		echo "Using RepoID: $PBI_BROWSE_RID"
 		echo "Searching for: $PBI_BROWSE_SEARCH"
 		grep -i -e "^App=" $PBI_BROWSE_METAFILE > ${PBI_TMPDIR}/.meta.$$
@@ -2032,7 +2032,7 @@
 		aName=`echo $line | cut -d ';' -f 1 2>/dev/null`
 
 		# Make sure this is from the correct category
-		if [ ! -z "$PBI_BROWSE_CAT" ] ; then
+		if [ -n "$PBI_BROWSE_CAT" ] ; then
 			_cCheck=`echo $catCheck | tr '[:lower:]' '[:upper:]'`
 			_cCheck2=`echo $PBI_BROWSE_CAT | tr '[:lower:]' '[:upper:]'`
 			if [ "$_cCheck" != "$_cCheck2" ]; then 
@@ -2076,12 +2076,12 @@
 
 		# Check for a translation to the description
 		get_meta_trans "App" "$cName" "${PBI_BROWSE_METAFILE}"
-		if [ ! -z "$MTRANS" ] ; then
+		if [ -n "$MTRANS" ] ; then
 			aDesc="$MTRANS"
 		fi
 
 		# Search the description / keywords
-		if [ ! -z "$PBI_BROWSE_SEARCH" ] ; then
+		if [ -n "$PBI_BROWSE_SEARCH" ] ; then
 			echo "$aName,$aDesc,$aKeywords,$MTRANS" | grep -i "$PBI_BROWSE_SEARCH" >/dev/null 2>/dev/null
 			if [ "$?" != "0" ]; then continue ; fi
 		fi
@@ -2093,10 +2093,10 @@
 		echo "------------------------------------"
 		echo "Application: $aName"
 		echo "Version: $PBI_UPNVER"
-		if [ ! -z "$PBI_UPSIZE" ] ; then
+		if [ -n "$PBI_UPSIZE" ] ; then
 			echo "Size: $PBI_UPSIZE"
 		fi
-		if [ ! -z "$PBI_BROWSE_LISTALLPBI" ] ; then
+		if [ -n "$PBI_BROWSE_LISTALLPBI" ] ; then
 			echo "Category: $catCheck"
 		fi
 		echo "Created: `echo $PBI_UPMDATE`"
@@ -2142,7 +2142,7 @@
 		
 		# Check for a translation to the description
 		get_meta_trans "Cat" "$cName" "${PBI_BROWSE_METAFILE}"
-		if [ ! -z "$MTRANS" ] ; then
+		if [ -n "$MTRANS" ] ; then
 			cDesc="$MTRANS"
 		fi
 
@@ -2176,7 +2176,7 @@
 	for l in $lCheck
 	do
 		catTrans=`grep "^${tag}\[$l\]=${name}" ${metaFile}`	
-		if [ ! -z "$catTrans" ] ; then
+		if [ -n "$catTrans" ] ; then
 			MTRANS=`echo $catTrans | cut -d ";" -f 2`
 			return
 		fi
@@ -2192,15 +2192,15 @@
 	if [ -z "$PBI_LISTREPO_ID" ] ; then
 		list_all_pbi_repo
 	else
-		if [ ! -z "${PBI_LISTREPO_UP}" ]; then
+		if [ -n "${PBI_LISTREPO_UP}" ]; then
 			require_root
 			move_repo_up "${PBI_LISTREPO_ID}" 
 			list_all_pbi_repo
-		elif [ ! -z "${PBI_LISTREPO_DOWN}" ] ; then
+		elif [ -n "${PBI_LISTREPO_DOWN}" ] ; then
 			require_root
 			move_repo_down "${PBI_LISTREPO_ID}"
 			list_all_pbi_repo
-		elif [ ! -z "${PBI_LISTREPO_MIRROR}" ] ; then
+		elif [ -n "${PBI_LISTREPO_MIRROR}" ] ; then
 			require_root
 			change_repo_mirror "${PBI_LISTREPO_ID}"
 			listrepo_details "${PBI_LISTREPO_ID}"
@@ -2637,11 +2637,11 @@
 	echo "-----------------------------------------------------"
 	echo "Name: ${PBI_PROGNAME}"
 
-	if [ ! -z "$PBI_PATCHVERSION" ] ; then
+	if [ -n "$PBI_PATCHVERSION" ] ; then
 		echo "PatchTarget: $PBI_PATCHTARGET"
 	fi
 
-	if [ ! -z "$PBI_INSTALLED_BY" ] ; then
+	if [ -n "$PBI_INSTALLED_BY" ] ; then
 		echo "InstalledBy: $PBI_INSTALLED_BY"
 	fi
 
@@ -2669,7 +2669,7 @@
 		*) echo "Signature: <Unknown>" ;;
 	esac
 
-	if [ ! -z "${PBI_REPO}" ] ; then
+	if [ -n "${PBI_REPO}" ] ; then
 		local _rDesc="`cat ${PBI_DBREPODIR}/*.${PBI_REPO} | grep "Desc:" | sed 's|Desc: ||g'`"
 		local _rID="`ls ${PBI_DBREPODIR}/*.${PBI_REPO}`"
 		_rID=`basename $_rID | cut -d '.' -f 1`
@@ -2942,7 +2942,7 @@
 		file="`echo $hl | sed 's/:::.*$//g'`"
 
 		# If we are trying to merge a PBI which was deleted, stop
-		if [ ! -z "${2}" -a -e "${2}" ] ; then
+		if [ -n "${2}" -a -e "${2}" ] ; then
 			echo "HASHDONE - Deleted" 
 			return
 		fi
@@ -3048,7 +3048,7 @@
         tar cvf - -C "${PBI_HEADER_TMPDIR}" . 2>/dev/null | tar xvf - -C "$dir" 2>/dev/null
 
 	# If this was a patch, use the original path
-	if [ ! -z "${PBI_ORIGPROGDIRPATH}" ] ; then
+	if [ -n "${PBI_ORIGPROGDIRPATH}" ] ; then
 		echo "${PBI_ORIGPROGDIRPATH}" >${dir}/pbi_installedpath
 	else
 		echo "${PBI_PROGDIRPATH}" >${dir}/pbi_installedpath
@@ -3056,7 +3056,7 @@
 
 	# See which repo / key this PBI associates to, if any
 	check_valid_sigs "${dir}"
-	if [ ! -z "$PBI_VALIDKEYSIG" ] ; then
+	if [ -n "$PBI_VALIDKEYSIG" ] ; then
 		_rMd5="`echo ${PBI_VALIDKEYSIG} | cut -d '.' -f 1`"
 		echo "$_rMd5" | sed "s|${PBI_DBKEYDIR}/||g" > ${dir}/pbi_repo
 	fi
@@ -3334,7 +3334,7 @@
 
 		# Check if this hash file is excluded
 		_hfound="0"
-		if [ ! -z "${PBI_HASH_EXCLUDES}" ] ; then
+		if [ -n "${PBI_HASH_EXCLUDES}" ] ; then
 			for _hexcl in ${PBI_HASH_EXCLUDES}
 			do
 				if [ "$_hexcl" = "$line" ] ; then
@@ -3809,7 +3809,7 @@
 	mkdir -p ${PBI_STAGEDIR}
 
 	# Build module list of excludes
-	if [ ! -z "$PBI_EXCLUDELIST" ] ; then
+	if [ -n "$PBI_EXCLUDELIST" ] ; then
 		for excl in $PBI_EXCLUDELIST
 		do
 			if [ -z "$_excOpts" ] ; then
@@ -3932,7 +3932,7 @@
 	fi
 
 	# Copy over our icon
-	if [ ! -z "${PBI_PROGICON}" -a -e "${PBI_STAGEDIR}/${PBI_PROGICON}" ] ; then
+	if [ -n "${PBI_PROGICON}" -a -e "${PBI_STAGEDIR}/${PBI_PROGICON}" ] ; then
 		# Get the file extension
 		_iconExt=`echo "$PBI_PROGICON" | awk -F . '{print $NF}'`
 		cp "${PBI_STAGEDIR}/${PBI_PROGICON}" "${PBI_HEADERDIR}/pbi_icon.${_iconExt}"
@@ -3980,7 +3980,7 @@
 
 # All the pieces are ready, spit out the final PBI file
 mk_output_pbi() {
-        if [ ! -z "${PBI_PROGICON}" -a -e "${PBI_STAGEDIR}/${PBI_PROGICON}" ] ; then
+        if [ -n "${PBI_PROGICON}" -a -e "${PBI_STAGEDIR}/${PBI_PROGICON}" ] ; then
                 icon="${PBI_STAGEDIR}/${PBI_PROGICON}"
         else
                 icon="${PBI_DEFAULT_ICON_CHROOT}"
@@ -4322,7 +4322,7 @@
 		check_autoupdate_pbis "$_pbid_log" "$_redir"
 
 		# Check if we need to merge files into the hashdir
-		if [ ! -z "`ls ${PBI_DBHASHQUEUEDIR}`" ] ; then
+		if [ -n "`ls ${PBI_DBHASHQUEUEDIR}`" ] ; then
 			init_tmpdir
 			for _hpbi in `ls ${PBI_DBHASHQUEUEDIR}`
 			do
@@ -4716,13 +4716,13 @@
 	check_enable_disable_auto
 
 	# Stop here if we are just enabling / disabling auto-update
-	if [ ! -z "$PBI_UPENABLEAUTO" ] ; then return 0 ; fi
+	if [ -n "$PBI_UPENABLEAUTO" ] ; then return 0 ; fi
 
 	start_update_checks
 	if [ "$?" != "0" ] ; then rm_tmpdir ; exit 1 ; fi
 
 	# Stop here if only doing update checks
-	if [ ! -z "${PBI_UPCHECK}" ]; then return 0 ; fi
+	if [ -n "${PBI_UPCHECK}" ]; then return 0 ; fi
 
   	require_root_or_group
 
@@ -4749,7 +4749,7 @@
 
         # See which repo / key this PBI associates to, if any
 	check_valid_sigs "${1}"
-	if [ "$?" = "0" -a ! -z "$PBI_VALIDKEYSIG" ] ; then
+	if [ "$?" = "0" -a -n "$PBI_VALIDKEYSIG" ] ; then
 		_rMd5="`echo ${PBI_VALIDKEYSIG} | cut -d '.' -f 1`"
 		echo "$_rMd5" | sed "s|${PBI_DBKEYDIR}/||g" > ${1}/pbi_repo
 	fi
@@ -4981,7 +4981,7 @@
 		PBI_UPMIRROR="`cat ${PBI_DBMIRRORDIR}/${_rMd5} 2>/dev/null`"
 		PBI_UPREPO="${_rMd5}"
 
-		if [ ! -z "${PBI_UPNVER}" ] ; then break; fi
+		if [ -n "${PBI_UPNVER}" ] ; then break; fi
 		if [ "${_urepo}" != "AUTO" ] ; then break; fi
 
 	done
@@ -4990,7 +4990,7 @@
 	if [ -z "$PBI_UPNVER" ] ; then return 1 ; fi
 
 	# See if this update is newer than the installed date
-	if [ ! -z "$_omdate" ] ; then
+	if [ -n "$_omdate" ] ; then
 		nDay=`echo $PBI_UPMDATE | cut -d ' ' -f 1`
 		nHour=`echo $PBI_UPMDATE | cut -d ' ' -f 2`
 		oDay=`echo $_omdate | cut -d ' ' -f 1`
@@ -5016,7 +5016,7 @@
 
 # Start PBI update process
 do_pbi_update() {
-	if [ ! -z "${PBI_UPCHECK}" ]; then return 0 ; fi
+	if [ -n "${PBI_UPCHECK}" ]; then return 0 ; fi
 
 	if [ "$PBI_UPDATEAPP" = "ALL" ] ; then
 		# Loop and check all PBIs for updates
@@ -5054,10 +5054,10 @@
 
 	# Check if the user overrode the arch / versions we want to install
 	_rArch=`uname -m`
-	if [ ! -z "$PBI_ADD_ALTARCH" ] ; then _rArch=$PBI_ADD_ALTARCH ; fi
+	if [ -n "$PBI_ADD_ALTARCH" ] ; then _rArch=$PBI_ADD_ALTARCH ; fi
 
 	_rVer="current"
-	if [ ! -z "$PBI_ADD_ALTVER" ] ; then _rVer=$PBI_ADD_ALTVER ; fi
+	if [ -n "$PBI_ADD_ALTVER" ] ; then _rVer=$PBI_ADD_ALTVER ; fi
 
 
 	check_pbi_update "$_rtar" "nodisplay" \
@@ -5200,7 +5200,7 @@
 	_dl_loc="${PBI_APPDIR}/.`basename $PBI_UPFILE`.$$"
 
 	# Have a patch file to download instead, make that the active file to try
-	if [ ! -z "$_tPatch" ] ; then
+	if [ -n "$_tPatch" ] ; then
 		_bDir=`dirname $PBI_UPFILE`
 		_uFile="${_bDir}/${_tPatch}"
 	else
@@ -5350,7 +5350,7 @@
 		. ${pbi}
 
 		# If we have a PBI already and this one has no version we can continue
-	        if [ -z "${PBI_AB_PRIORITY}" -a ! -z "${CUR_WORKING_PBI}"  ] ; then continue ; fi
+	        if [ -z "${PBI_AB_PRIORITY}" -a -n "${CUR_WORKING_PBI}"  ] ; then continue ; fi
 
 		_cd=$(dirname $pbi | sed 's|./||')
 
@@ -5446,7 +5446,7 @@
 	do
 		if [ "${i}" = "." -o "${i}" = ".." ] ; then continue ; fi
 		_pDir=`dirname ${i}`
-		if [ -d "${i}" -a ! -z "${i}" ] ; then
+		if [ -d "${i}" -a -n "${i}" ] ; then
     			if [ ! -e "${PBI_AB_CONFDIR}/${_pDir}" ] ; then
       			# Not in our module tree anymore, remove it
       			echo "Auto-Prune: ${PBI_AB_OUTDIR}/${_pDir}"
@@ -5467,7 +5467,7 @@
 	local _abkey="$6"
 	_flags=""
 	_flags="-c ${_cd} -d ${PORTSDIR} -o ${_od} --delbuild"
-	if [ ! -z "${PBI_AB_SSLPRIVKEY}" ] ; then
+	if [ -n "${PBI_AB_SSLPRIVKEY}" ] ; then
 		_flags="${_flags} --sign ${PBI_AB_SSLPRIVKEY}"
 	fi
 
@@ -5488,7 +5488,7 @@
 	echo "$_abkey" > ${_od}/.abkey
 	
 	# Save the build key for this PBI
-	if [ ! -z "$_bk" ] ; then
+	if [ -n "$_bk" ] ; then
 		echo "$_bk" > "${_od}/pbi-buildkey"
 	else
 		echo "__NONE__" > "${_od}/pbi-buildkey"
@@ -5528,7 +5528,7 @@
 		# Save the mdate file
 		date "+%Y%m%d %H%M%S" >${_od}/pbi-mdate
 
-		if [ ! -z "${PBI_AB_HELPS}" ] ; then
+		if [ -n "${PBI_AB_HELPS}" ] ; then
 			${PBI_AB_HELPS} "OK" "${_od}"
 		fi
 
@@ -5553,7 +5553,7 @@
 		tar cvf - -C "${PORTSDIR}/${_mp}" . 2>/dev/null | md5 -q >${_od}/.failed-csum
 
 		echo "Failed" > "${_od}/pbi-result"
-		if [ ! -z "${PBI_AB_HELPS}" ] ; then
+		if [ -n "${PBI_AB_HELPS}" ] ; then
 			${PBI_AB_HELPS} "FAILED" "${_od}"
 		fi
 	fi
@@ -5571,7 +5571,7 @@
 	rm ${_curPBIdir}/*.pbp 2>/dev/null
 
 	# Make sure to enable signing of the patch files
-	if [ ! -z "${PBI_AB_SSLPRIVKEY}" ] ; then
+	if [ -n "${PBI_AB_SSLPRIVKEY}" ] ; then
         	local _mpflags="-o $_curPBIdir --sign ${PBI_AB_SSLPRIVKEY}"
 	else
 		local _mpflags="-o $_curPBIdir"
@@ -5655,7 +5655,7 @@
 	# Get a list of files which are removed in the new PBI vs the old
 	gen_rem_list "$_pbiNewDir/$_pbiNewPrefix" "$_pbiOldDir/$_pbiOldPrefix"
 	_rFileList="$VAL"
-	if [ ! -z "$_rFileList" ] ; then
+	if [ -n "$_rFileList" ] ; then
 		echo "Saving removed file list..."
 		mv "${_rFileList}" ${_pbiPatchDir}/PBI-rmList
 	fi
@@ -5663,7 +5663,7 @@
 	# Get archive of files/dirs which are new to the PBI
 	gen_newfile_list "$_pbiNewDir/$_pbiNewPrefix" "$_pbiOldDir/$_pbiOldPrefix"
 	_nFileList="$VAL"
-	if [ ! -z "$_nFileList" ] ; then
+	if [ -n "$_nFileList" ] ; then
 		echo "Saving new files archive..."
 		tar cvf "$_pbiPatchDir/PBI-newFiles.tar" \
 			-C "$_pbiNewDir/$_pbiNewPrefix" -T "$_nFileList" >/dev/null 2>/dev/null
@@ -5673,7 +5673,7 @@
 	# Get a listing of permissions
 	gen_chmod_list "$_pbiNewDir/$_pbiNewPrefix" "$_pbiOldDir/$_pbiOldPrefix"
 	_cFileList="$VAL"
-	if [ ! -z "$_cFileList" ] ; then
+	if [ -n "$_cFileList" ] ; then
 		echo "Saving permissions list..."
 		mv "${_cFileList}" ${_pbiPatchDir}/PBI-permList
 	fi
@@ -5979,7 +5979,7 @@
 	# Check PBI_BUILDKEY, see if we have a manual rebuild triggered
 	if [ -e "${PBI_AB_OUTDIR}/${_cd}/pbi-buildkey" ] ; then
 		if [ "`cat ${PBI_AB_OUTDIR}/${_cd}/pbi-buildkey`" != "$_bk" \
-			 -a ! -z "${_bk}" ]
+			 -a -n "${_bk}" ]
         	then echo "BUILDKEY bump, rebuild triggered." ; return 0 ; fi
 	fi
 
@@ -6146,9 +6146,9 @@
 
 # Clean the chroot environment
 chroot_make_cleanup() {
-	if [ -z "${PBI_CHROOTDIR}" ] ; then return ; fi
-	if [ ! -d "${PBI_CHROOTDIR}" ] ; then return ; fi
-	if [ "${PBI_CHROOTDIR}" = "/" ] ; then return ; fi
+	[ -z "${PBI_CHROOTDIR}" ] && return
+	[ -d "${PBI_CHROOTDIR}" ] || return
+	[ "${PBI_CHROOTDIR}" = "/" ] && return
 	
 	# Unmount /dev if mounted
 	echo "Cleaning $PBI_CHROOTDIR"
@@ -6168,7 +6168,7 @@
 chroot_extract() {
 
 	# If no chroot file exists, make it first
-	if [ ! -e "${PBI_CHROOTFILE}" ] ; then mk_chroot_file ; fi
+	[ -e "${PBI_CHROOTFILE}" ] || mk_chroot_file
 
 	# Set the chroot path
 	PBI_CHROOTDIR="${PBI_PROGDIRPATH}.chroot"
@@ -6180,23 +6180,17 @@
 	mkdir -p "${PBI_CHROOTDIR}"
 	echo "Extracting chroot environment..."
 	tar xvf ${PBI_CHROOTFILE} -C "${PBI_CHROOTDIR}" >/dev/null 2>/dev/null
-	if [ "$?" != "0" ] ; then
-		exit_err "Failed extracting chroot environment!"
-	fi
+	[ $? -ne 0 ] && exit_err "Failed extracting chroot environment!"
 
 	# Copy resolv.conf
 	cp /etc/resolv.conf ${PBI_CHROOTDIR}/etc/resolv.conf
 
 	# If we have a custom PBI_MAKECONF include it
-	if [ -e "${PBI_MAKECONF}" ] ; then
-		cp ${PBI_MAKECONF} ${PBI_CHROOTDIR}/etc/make.conf
-	fi
+	[ -e "${PBI_MAKECONF}" ] && cp ${PBI_MAKECONF} ${PBI_CHROOTDIR}/etc/make.conf
 
 	#echo "Copying ${PORTSDIR} -> ${PBI_CHROOTDIR}/usr/ports"
 	#tar cvf - -C "${PORTSDIR}" --exclude ./distfiles . 2>/dev/null | tar xvf - -C "${PBI_CHROOTDIR}/usr/ports" 2>/dev/null
-	if [ ! -d "${PORTSDIR}/distfiles" ] ; then
-		mkdir -p ${PORTSDIR}/distfiles
-	fi
+	[ -d "${PORTSDIR}/distfiles" ] || mkdir -p ${PORTSDIR}/distfiles
 	mkdir -p ${PBI_CHROOTDIR}/usr/ports
 	mount_nullfs ${PORTSDIR} ${PBI_CHROOTDIR}/usr/ports
 
@@ -6222,26 +6216,26 @@
 	cp -r ${PBI_DBDIR} ${PBI_CHROOTDIR}${PBI_DBDIR}
 	
 	# Copy over the confdir as well
-	if [ ! -z "${PBI_CONFDIR}" ] ; then
+	if [ -n "${PBI_CONFDIR}" ] ; then
 		mkdir -p "${PBI_CHROOTDIR}/pbimodule"
 		echo "Copying ${PBI_CONFDIR} -> ${PBI_CHROOTDIR}/pbimodule"
 	 	tar cvf - -C "${PBI_CONFDIR}" . 2>/dev/null | tar xvf - -C "${PBI_CHROOTDIR}/pbimodule" 2>/dev/null
 	fi
 
 	# Copy over the ssl priv key if used
-	if [ ! -z "$PBI_SSLPRIVKEY" ] ; then
+	if [ -n "$PBI_SSLPRIVKEY" ] ; then
 	 	cp "${PBI_SSLPRIVKEY}" "${PBI_CHROOTDIR}/privkey.pem"
 		chmod 600 "${PBI_CHROOTDIR}/privkey.pem"
 	fi
 
 	# Check if we have a pre-make script to run
-	if [ ! -z "${PBI_PREMAKE_SCRIPT}" ] ; then
+	if [ -n "${PBI_PREMAKE_SCRIPT}" ] ; then
 		if [ -e "${PBI_PREMAKE_SCRIPT}" ] ; then
 			cp ${PBI_PREMAKE_SCRIPT} ${PBI_CHROOTDIR}/pre-build.sh
 		fi
 	fi
 	# Check if we have a post-make script to run
-	if [ ! -z "${PBI_POSTMAKE_SCRIPT}" ] ; then
+	if [ -n "${PBI_POSTMAKE_SCRIPT}" ] ; then
 		if [ -e "${PBI_POSTMAKE_SCRIPT}" ] ; then
 			cp ${PBI_POSTMAKE_SCRIPT} ${PBI_CHROOTDIR}/post-build.sh
 		fi
@@ -6261,7 +6255,7 @@
 	mkdir -p ${PBI_CHROOTDIR}${PBI_CREATE_OUTDIR} >/dev/null 2>/dev/null
 
 	# Check for ccache being enabled on the host and nullfs mount it to the chroot
-	if [ ! -z "${CCACHE_DIR}" -a -d "${CCACHE_DIR}" ] ; then
+	if [ -n "${CCACHE_DIR}" -a -d "${CCACHE_DIR}" ] ; then
 		mkdir ${PBI_CHROOTDIR}/.ccache
 		mount_nullfs ${CCACHE_DIR} ${PBI_CHROOTDIR}/.ccache	
 	fi
@@ -6277,7 +6271,7 @@
 	  cd "$PBI_APPDIR"
 
 	  # Set the mirror URL
-  	  MIRRORURL="`cat ${PCBSD_ETCCONF} | grep 'PCBSD_MIRROR: ' | sed 's|PCBSD_MIRROR:||g'`"
+  	  MIRRORURL="`sed -n 's/PCBSD_MIRROR: //p' ${PCBSD_ETCCONF}`"
 
   	  # Get the system version we are checking for updates to
   	  SYSVER="`pbreg get /PC-BSD/Version`" ; export SYSVER
@@ -6290,9 +6284,7 @@
   	  fetch -o rel.tbz ${MIRRORURL}/${SYSVER}/${ARCH}/netinstall/fbsd-release.tbz
     	  fetch -o rel.md5 ${MIRRORURL}/${SYSVER}/${ARCH}/netinstall/fbsd-release.tbz.md5
 
-    	  if [ `md5 -q rel.tbz` != `cat rel.md5` ] ; then
-    	    exit_err "Error in download data, checksum mismatch.. Please try again later."
-	  fi
+    	  [ `md5 -q rel.tbz` != `cat rel.md5` ] && exit_err "Error in download data, checksum mismatch.. Please try again later."
 
 	  mv rel.tbz ${PBI_CHROOTFILE}
 	  rm rel.md5
@@ -6310,9 +6302,7 @@
 	else
 		# Make sure SVN is installed
 		which svn >/dev/null 2>/dev/null
-		if [ "$?" != "0" ] ; then
-			exit_err "Subversion is required to rebuild the chroot environment!"
-		fi
+		[ "$?" -ne 0 ] && exit_err "Subversion is required to rebuild the chroot environment!"
 
 		echo "Building the PBI chroot environment... This may take a while..."
 		PBI_BUILDSRC="${PBI_APPDIR}/.tmpSRC.$$"
@@ -6324,33 +6314,31 @@
 	
 		# Figure out which version of FreeBSD to checkout
 		local _osRel=`uname -r`
-		echo $_osRel | grep "RELEASE" >/dev/null 2>/dev/null
-		if [ "$?" = "0" ] ; then
-			local _osMajor=`echo $_osRel | cut -c 1-1`
-			local svnUrl="svn://svn.freebsd.org/base/releng/${_osMajor}.0"
-			echo "Using $svnUrl for sources"
-		else
-			echo $_osRel | grep "CURRENT" >/dev/null 2>/dev/null
-			if [ "$?" = "0" ] ; then
-		    	      local svnUrl="svn://svn.freebsd.org/base/head"
-			      echo "Using $svnUrl for sources"
-			else
-		   	   echo $_osRel | grep "STABLE" >/dev/null 2>/dev/null
-			      if [ "$?" = "0" ] ; then
-				    local _osMajor=`echo $_osRel | cut -c 1-1`
-				    local svnUrl="svn://svn.freebsd.org/base/stable/${_osMajor}"
-				    "Using $svnUrl for sources"
-			      else
-			   	 local svnUrl="svn://svn.freebsd.org/base/head"
-			    	echo "Using $svnUrl for sources"
-				    echo "Assuming a BETA|RC or rarely used FreeBSD version. Using CURRENT!"
-			      fi
-			fi
-		fi
+		case $_osRel in
+			*RELEASE)
+				local _osMajor=${_osRel%%.*}
+				local svnUrl="svn://svn.freebsd.org/base/releng/${_osMajor}.0"
+				echo "Using $svnUrl for sources"
+				;;
+			*CURRENT)
+				local svnUrl="svn://svn.freebsd.org/base/head"
+				echo "Using $svnUrl for sources"
+				;;
+			*STABLE)
+				local _osMajor=${_osRel%%.*}
+				local svnUrl="svn://svn.freebsd.org/base/stable/${_osMajor}"
+				"Using $svnUrl for sources"
+				;;
+			*)
+				local svnUrl="svn://svn.freebsd.org/base/head"
+				echo "Using $svnUrl for sources"
+				echo "Assuming a BETA|RC or rarely used FreeBSD version. Using CURRENT!"
+				;;
+		esac
 
 		echo "Checking out FreeBSD sources from $svnUrl"
 		svn co ${svnUrl} ${PBI_BUILDSRC} >>${PBI_BUILDLOG} 2>>${PBI_BUILDLOG}
-		if [ "$?" != "0" ] ; then
+		if [ $? -ne 0 ] ; then
 			rm -rf "${PBI_BUILDSRC}"
 			rm -rf "${PBI_BUILDTARGET}"
 			exit_err "Subversion checkout failed! Logfile saved: ${PBI_BUILDLOG}"
@@ -6360,9 +6348,9 @@
 	echo "Running buildworld / installworld"
 	cd ${PBI_BUILDSRC}
 	make buildworld installworld distribution DESTDIR=${PBI_BUILDTARGET} >>${PBI_BUILDLOG} 2>>${PBI_BUILDLOG}
-	if [ "$?" != "0" ] ; then
+	if [ $? -ne 0 ] ; then
 		cd
-		if [ "${PBI_BUILDSRC}" != "/usr/src" ] ; then rm -rf "${PBI_BUILDSRC}"; fi
+		[ "${PBI_BUILDSRC}" != "/usr/src" ] && rm -rf "${PBI_BUILDSRC}"
 		rm -rf "${PBI_BUILDTARGET}"
 		exit_err "Buildworld failed! Logfile saved: ${PBI_BUILDLOG}"
 	fi
@@ -6374,9 +6362,9 @@
 
 	echo "Creating chroot environment tarball"
 	tar cvjf ${PBI_CHROOTFILE} -C ${PBI_BUILDTARGET} . >>${PBI_BUILDLOG} 2>>${PBI_BUILDLOG}
-	if [ "$?" != "0" ] ; then
+	if [ $? -ne 0 ] ; then
 		cd
-		if [ "${PBI_BUILDSRC}" != "/usr/src" ] ; then rm -rf "${PBI_BUILDSRC}"; fi
+		[ "${PBI_BUILDSRC}" != "/usr/src" ] && rm -rf "${PBI_BUILDSRC}"
 		rm -rf "${PBI_BUILDTARGET}"
 		rm -rf "${PBI_CHROOTFILE}"
 		exit_err "Making chroot environment tarball failed! Logfile saved: ${PBI_BUILDLOG}"
@@ -6384,7 +6372,7 @@
 
 	# Cleanup after ourselves
 	chflags -R noschg "${PBI_BUILDTARGET}" >/dev/null 2>/dev/null
-	if [ "${PBI_BUILDSRC}" != "/usr/src" ] ; then rm -rf "${PBI_BUILDSRC}"; fi
+	[ "${PBI_BUILDSRC}" != "/usr/src" ] && rm -rf "${PBI_BUILDSRC}"
 	rm -rf "${PBI_BUILDTARGET}" >/dev/null 2>/dev/null
 	rm ${PBI_BUILDLOG}
 }
@@ -6404,20 +6392,17 @@
 
 	_ef="${PBI_PROGDIRPATH}/${MOD_AUTOEXTLINKFILE}"
 
-	if [ -e "$_ef" ]; then rm "$_ef" ; fi
+	[ -e "$_ef" ] && rm "$_ef"
 
 	while read f
 	do
 		bin="NO"
-		if [ -z "${f}" ] ; then continue ; fi 
-		if [ ! -e "${PBI_PROGDIRPATH}/${f}" ] ; then continue ; fi 
+		[ -z "${f}" ] && continue
+		[ -e "${PBI_PROGDIRPATH}/${f}" ] || continue
 
 		# See if this is executable and set it as binary
 		dirname ${f} | grep -e "bin" -e "sbin" >/dev/null 2>/dev/null
-		if [ -x "${PBI_PROGDIRPATH}/${f}" -a "$?" = "0" ]; then bin="YES" ; fi
-
-		# If we are working on a binary, mark it as such
-		if  [ "$bin" = "YES" ] ; then
+		if [ -x "${PBI_PROGDIRPATH}/${f}" -a $? -eq 0 ] ; then
 			echo "${f}	${f}	binary,nocrash" >> "$_ef"
 		else
 			echo "${f}	${f}	replace" >> "$_ef"
@@ -6432,7 +6417,7 @@
  	for _dsd in $DBUS_SEARCH_DIRS
 	do
 		# Check if we have a valid dbus directory
-		if [ ! -d "${PBI_PROGDIRPATH}/${_dsd}" ] ; then continue ; fi
+		[ -d "${PBI_PROGDIRPATH}/${_dsd}" ] || continue
 
 		# Make a list of files to include
 		find ${PBI_PROGDIRPATH}/${_dsd} -type f | sed "s|${PBI_PROGDIRPATH}/${_dsd}/||g" > ${PBI_TMPDIR}/.dbus.$$
@@ -6441,29 +6426,23 @@
 		while read _dbfile
 		do
 			# Get the file extension, only .xml and .service are valid
-			echo "${_dsd}/${_dbfile}" | grep -e ".xml" -e ".service" >/dev/null 2>/dev/null
-			if [ "$?" != "0" ]; then continue ; fi
+			case "${_dsd}/${_dbfile}" in
+				*.xml) dbext=".xml" ;;
+				*.service)
+					dbext=".service"
 
-			# Check if this is a .service or .xml file
-		 	echo "${_dsd}/$_dbfile" | grep ".service" >/dev/null 2>/dev/null
-			if [ "$?" = "0" ] ; then
-				dbext=".service"
+					# We have a service file, find the target binary and make sure its added as a wrapper only
+					_dbbin="`grep 'Exec' ${PBI_PROGDIRPATH}/${_dsd}/${_dbfile} | cut -d '=' -f 2 | cut -d ' ' -f 1`"
+					_dbbin=`echo "$_dbbin" | sed "s|${PBI_PROGDIRPATH}/||g"`
+					[ -n "$_dbbin" ] && echo "${_dbbin}		${_dbbin}	binwrapper" >> "$_ef"
 
-				# We have a service file, find the target binary and make sure its added as a wrapper only
-				_dbbin="`grep 'Exec' ${PBI_PROGDIRPATH}/${_dsd}/${_dbfile} | cut -d '=' -f 2 | cut -d ' ' -f 1`"
-				_dbbin=`echo "$_dbbin" | sed "s|${PBI_PROGDIRPATH}/||g"`
-				if [ ! -z "$_dbbin" ] ; then
-				echo "${_dbbin}		${_dbbin}	binwrapper" >> "$_ef"
-				fi
+					# Massage the service file to point to the fakebin wrapper
+					rmBaseDir="`dirname ${_dbbin}`"
+					sed -i '' "s|${PBI_PROGDIRPATH}/${rmBaseDir}/|${PBI_PROGDIRPATH}/${PBI_FAKEBIN_DIR}/|g" "${PBI_PROGDIRPATH}/${_dsd}/${_dbfile}"
+					;;
+				*) continue ;;
+			esac
 
-				# Massage the service file to point to the fakebin wrapper
-				rmBaseDir="`dirname ${_dbbin}`"
-	                        sed -i.bak "s|${PBI_PROGDIRPATH}/${rmBaseDir}/|${PBI_PROGDIRPATH}/${PBI_FAKEBIN_DIR}/|g" "${PBI_PROGDIRPATH}/${_dsd}/${_dbfile}"
-	                        rm "${PBI_PROGDIRPATH}/${_dsd}/${_dbfile}.bak"
-			else
-				dbext=".xml"
-			fi
-
 			echo "${_dsd}/${_dbfile}	${_dsd}/${_dbfile}.${_pname}.${dbext}	replace" >> "$_ef"
 		done < ${PBI_TMPDIR}/.dbus.$$
 		rm ${PBI_TMPDIR}/.dbus.$$
@@ -6475,7 +6454,7 @@
 # Init the crash handler routine
 pbi_crash_init() {
 	which "pbi-crashhandler-gui" >/dev/null 2>/dev/null
-	if [ "$?" = "0" -a ! -z "${DISPLAY}" ] ; then
+	if [ "$?" = "0" -a -n "${DISPLAY}" ] ; then
 		#pbi-crashhandler-gui "$@"
 	fi
 }
@@ -6488,7 +6467,7 @@
 # Cleanup after caught exit
 exit_trap() {
 	# If a download is running, kill it
-	if [ ! -z "${FETCH_PID}" ] ; then 
+	if [ -n  "${FETCH_PID}" ] ; then 
 	   echo "Killing ${FETCH_PID}"
 	   kill -9 ${FETCH_PID}
 	   sleep 1



More information about the Commits mailing list