changeset 181:d3b7927bdb2b

restructuring and add check if the xml is processed properly
author edhoprima@gmail.com <edhoprima@gmail.com>
date Sun, 28 Jun 2009 05:12:41 +0000
parents 8e6555aa8631
children d92dfe857047
files moefetch.sh
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/moefetch.sh	Fri Jun 05 21:13:37 2009 +0000
+++ b/moefetch.sh	Sun Jun 28 05:12:41 2009 +0000
@@ -87,7 +87,9 @@
 </xsl:template>
 </xsl:stylesheet>
 EOF
-	echo "`echo \`wc -l < \"${SITE_DIR}-${TARGET_DIR}-list\" \`` file(s) available on server"
+	NUMFILES=`echo \`wc -l < \"${SITE_DIR}-${TARGET_DIR}-list\" \``
+	[ "${NUMFILES}" -gt 0 ] || Err_Fatal "Error in processing list or no files can be found with specified tag(s) or site"
+	echo "${NUMFILES}" file(s) available on server"
 	#output file: ${TARGET_DIR}-list
 }
 
@@ -227,12 +229,8 @@
 
 # initialize base variables and initial command check
 Init(){
-	# Get base folder - current folder or fallback to ${HOME}
-	[ "${BASE_DIR}"	] || BASE_DIR="${PWD}"
-	[ "${BASE_DIR}" ] || BASE_DIR="{$HOME}"
-	[ "`echo ${BASE_DIR} | cut -c1 | grep \/`" ] || BASE_DIR="/${BASE_DIR}"	
 	# path initialization
-	[ "${ADDITIONAL_PATH}" ] && PATH=${ADDITIONAL_PATH}:${PATH}
+	[ "${ADDITIONAL_PATH}" ] && PATH="${ADDITIONAL_PATH}:${PATH}"
 	export PATH
 	
 	# misc variables
@@ -261,6 +259,11 @@
 			SITE="${DEFAULT_SITE}"
 		;;
 	esac
+	# Get base folder - default, current folder or fallback to ${HOME}
+	[ "${BASE_DIR}"	] || BASE_DIR="${PWD}"
+	[ "${BASE_DIR}" ] || BASE_DIR="{$HOME}"
+	[ "`echo ${BASE_DIR} | cut -c1 | grep \/`" ] || BASE_DIR="/${BASE_DIR}"	
+
 	TAGS="$@"
 	echo "Tags: ${TAGS}"
 	# slash is not wanted for folder name
@@ -268,6 +271,7 @@
 	SITE_DIR="`echo "${SITE}" | sed -e 's/\/$//g;s/\//_/g'`"
 }
 
+# initialization
 Msg_Welcome
 Init "$@"
 Check_Tools