Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Unified Diff: make_factory_package.sh

Issue 4688004: Make removing the last ] more full-proof (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: Cleaned up ifs and quoted paths Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: make_factory_package.sh
diff --git a/make_factory_package.sh b/make_factory_package.sh
index 9a44f71dd24d6d9e8a4a48495365578492c13b6d..cfc25cbc9e73920549b5b7f430bd0d106738270d 100755
--- a/make_factory_package.sh
+++ b/make_factory_package.sh
@@ -166,9 +166,28 @@ fi
if [ -n "${FLAGS_subfolder}" ] && \
[ -f "${OMAHA_DIR}"/miniomaha.conf"" ] ; then
# Remove the ']' from the last line of the file so we can add another config.
- sed -i '$d' ${OMAHA_DIR}/miniomaha.conf
+ while [ -s "${OMAHA_DIR}/miniomaha.conf" ]; do
+ # If the last line is null
+ if [ -z "$(tail -1 "${OMAHA_DIR}/miniomaha.conf")" ]; then
+ sed -i '$d' "${OMAHA_DIR}/miniomaha.conf"
+ elif [ "$(tail -1 "${OMAHA_DIR}/miniomaha.conf")" != ']' ]; then
+ sed -i '$d' "${OMAHA_DIR}/miniomaha.conf"
+ else
+ break
+ fi
+ done
+
+ # Remove the last ]
+ if [ "$(tail -1 "${OMAHA_DIR}/miniomaha.conf")" '=' ']' ]; then
Hung-Te 2010/11/12 00:27:12 You don't need the single quote for the =
+ sed -i '$d' "${OMAHA_DIR}/miniomaha.conf"
+ fi
+
+ # If the file is empty, create it from scratch
+ if [ ! -s "${OMAHA_DIR}/miniomaha.conf" ]; then
+ echo "config = [" > "${OMAHA_DIR}/miniomaha.conf"
+ fi
else
- echo -e "config = [" > ${OMAHA_DIR}/miniomaha.conf
+ echo "config = [" > "${OMAHA_DIR}/miniomaha.conf"
fi
if [ -n "${FLAGS_subfolder}" ] ; then
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698