mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-24 23:21:17 +02:00
Make removing the last ] more full-proof
Make removal of last ] more full-proof Change-Id: I002e5ed513066a214fd6353f66e05bf5458f6ad4 BUG=7115 TEST= No file, with --subfolder No file, without --subfolder Empty file File with one config already in it, with --subfolder File with one config and garbage at the end, with --subfolder File with one config and newlines at the end, with --subfolder File with one config, without subfolder Review URL: http://codereview.chromium.org/4688004
This commit is contained in:
parent
37f4222632
commit
43c22803a1
@ -218,9 +218,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
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user