- use sed with inline option to avoid leaving temporary files behind

OBS-URL: https://build.opensuse.org/package/show/X11:common:Factory/update-desktop-files?expand=0&rev=34
This commit is contained in:
Stephan Kulow 2011-12-16 09:49:52 +00:00 committed by Git OBS Bridge
parent c673b3f4ef
commit b55411cec7
3 changed files with 32 additions and 30 deletions

View File

@ -275,26 +275,24 @@ done
echo "" >> "${FILE}"
CAT="${CAT#;}"
if grep -q ^Categories= $FILE; then
sed -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^Categories=.*,Categories='${CAT}',' "$FILE" > "${FILE}.new" &&
mv "${FILE}.new" "${FILE}"
sed -i -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^Categories=.*,Categories='${CAT}',' "$FILE"
else
if [ -n "${CAT%;}" ]; then
sed -e '/^\[Desktop Entry\]/a \
'"Categories=${CAT%;};" $FILE > ${FILE}_ && mv ${FILE}_ $FILE
sed -i -e '/^\[Desktop Entry\]/a \
'"Categories=${CAT%;};" $FILE
fi
fi
if [ "$UNIMPORTANT" = "yes" ]; then
if grep -q ^NoDisplay= $FILE; then
sed -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^NoDisplay=.*,NoDisplay=true,' "$FILE" > "${FILE}.new" &&
mv "${FILE}.new" "${FILE}"
sed -i -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^NoDisplay=.*,NoDisplay=true,' "$FILE"
else
sed -e '/^\[Desktop Entry\]/a \
NoDisplay=true' $FILE > ${FILE}_ && mv ${FILE}_ $FILE
sed -i -e '/^\[Desktop Entry\]/a \
NoDisplay=true' $FILE
fi
fi
if [ "$DOCID" ]; then
sed -e '/^\[Desktop Entry\]/a \
'"X-SuSE-DocTeamID=$DOCID" $FILE > ${FILE}_ && mv ${FILE}_ $FILE
sed -i -e '/^\[Desktop Entry\]/a \
'"X-SuSE-DocTeamID=$DOCID" $FILE
fi
#
@ -324,8 +322,8 @@ if [ -n "$DOCPATH" ] ; then
mv "${FILE}.new" "${FILE}"
fi
else
sed -e '/^\[Desktop Entry\]/a \
'"DocPath=${DOCPATH}" $FILE > ${FILE}.new && mv ${FILE}.new $FILE
sed -i -e '/^\[Desktop Entry\]/a \
'"DocPath=${DOCPATH}" $FILE
if $DOCPATH_IS_GUESS ; then
echo NOTE: suse_update_desktop_file: Guessing DocPath=$DOCPATH in $FILE
fi
@ -338,41 +336,41 @@ if grep -q ^X-SuSE-translate= $FILE; then
fi
if [ "$NAME" != "no" ]; then
grep -v '^Name\[' $FILE > ${FILE}_
sed -i -e '/^Name\[/d' $FILE
if [ -n "$NAME" ]; then
if ! grep -q ^Name= ${FILE}_; then
sed -e '/^\[Desktop Entry\]/a '"Name=${NAME//,/\,}" ${FILE}_ > $FILE
if ! grep -q ^Name= ${FILE}; then
sed -i -e '/^\[Desktop Entry\]/a '"Name=${NAME//,/\,}" ${FILE}
else
sed -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^Name=.*,Name='"${NAME//,/\,}"',' ${FILE}_ > $FILE
sed -i -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^Name=.*,Name='"${NAME//,/\,}"',' ${FILE}
fi
else
grep -v "^Name=" ${FILE}_ > $FILE
sed -i -e '/^Name=/d' $FILE
fi
fi
if [ "$GNAME" != "no" ]; then
grep -v '^GenericName\[' $FILE > ${FILE}_
sed -i -e '/^GenericName\[/d' $FILE
if [ -n "$GNAME" ]; then
if ! grep -q ^GenericName= ${FILE}_; then
sed -e '/^\[Desktop Entry\]/a '"GenericName=${GNAME//,/\,}" ${FILE}_ > $FILE
sed -i -e '/^\[Desktop Entry\]/a '"GenericName=${GNAME//,/\,}" ${FILE}
else
sed -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^GenericName=.*,GenericName='"${GNAME//,/\,}"',' ${FILE}_ > $FILE
sed -i -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^GenericName=.*,GenericName='"${GNAME//,/\,}"',' ${FILE}
fi
else
grep -v "^GenericName=" ${FILE}_ > $FILE
sed -i -e '/^GenericName=/d' $FILE
fi
fi
if [ "$COMMENT" != "no" ]; then
grep -v '^Comment\[' $FILE > ${FILE}_
sed -i -e '/^Comment\[/d' $FILE
if [ -n "$COMMENT" ]; then
if ! grep -q ^Comment= ${FILE}_; then
sed -e '/^\[Desktop Entry\]/a '"Comment=${COMMENT//,/\,}" ${FILE}_ > $FILE
if ! grep -q ^Comment= ${FILE}; then
sed -i -e '/^\[Desktop Entry\]/a '"Comment=${COMMENT//,/\,}" ${FILE}
else
sed -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^Comment=.*,Comment='"${COMMENT//,/\,}"',' ${FILE}_ > $FILE
fi
sed -i -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^Comment=.*,Comment='"${COMMENT//,/\,}"',' ${FILE}
fi
else
grep -v "^Comment=" ${FILE}_ > $FILE
sed -i -e '/^Comment=/d' $FILE
fi
fi
@ -380,6 +378,6 @@ if [ "$I18N" = "no" ]; then
#
# this file will not get translated
#
sed -e '/^\[Desktop Entry\]/a \
X-SuSE-translate=false' $FILE > ${FILE}_ && mv ${FILE}_ $FILE
sed -i -e '/^\[Desktop Entry\]/a \
X-SuSE-translate=false' $FILE
fi

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Fri Dec 16 09:49:24 UTC 2011 - coolo@suse.com
- use sed with inline option to avoid leaving temporary files behind
-------------------------------------------------------------------
Thu Dec 15 12:44:49 UTC 2011 - coolo@suse.com

View File

@ -15,7 +15,6 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
Name: update-desktop-files
Version: 12.1
Release: 0