summarylogtreecommitdiffstats
path: root/geany-openscad.install
diff options
context:
space:
mode:
Diffstat (limited to 'geany-openscad.install')
-rw-r--r--geany-openscad.install41
1 files changed, 21 insertions, 20 deletions
diff --git a/geany-openscad.install b/geany-openscad.install
index f02b7aface6f..a71f4a8c1993 100644
--- a/geany-openscad.install
+++ b/geany-openscad.install
@@ -7,29 +7,30 @@ declare -r key='OpenSCAD'
declare -r value='*.scad'
post_install() {
- # insert filetype line if it isn't present, otherwise replace it.
- if [ -z "`grep "^${key}=" "${file}"`" ] ; then
- local before="`sed -n "1,/^\[${heading}]/p" "${file}"`"
- local section="`sed "1,/^\[${heading}]/d;/^\s*$/,\\\$d" $file | \
- cat - <(echo "${key}=${value};") | \
- sort -f`"
- local after="`sed "1,/^\[${heading}]/d;1,/^\s*$/d" "${file}"`"
+ # insert filetype line if it isn't present, otherwise replace it.
+ if [ -z "`grep "^${key}=" "${file}"`" ] ; then
+ local before="`sed -n "1,/^\[${heading}]/p" "${file}"`"
+ local section="`sed "1,/^\[${heading}]/d;/^\s*$/,\\\$d" $file | \
+ cat - <(echo "${key}=${value};") | \
+ sort -f`"
+ local after="`sed "1,/^\[${heading}]/d;1,/^\s*$/d" "${file}"`"
- echo -e "${before}\n${section}\n\n${after}" > "${file}"
- else
- sed -i "s/^\(${key}=.*;\)/\1${value};/" "${file}"
- fi
- sed -i "s/^\(${category}=.*\)/\1${key};/" "${file}"
+ echo -e "${before}\n${section}\n\n${after}" > "${file}"
+ else
+ sed -i "s/^\(${key}=.*;\)/\1${value};/" "${file}"
+ fi
+
+ sed -i "s/^\(${category}=.*\)/\1${key};/" "${file}"
}
pre_remove() {
- # remove the *.scad pattern from the OpenSCAD file type.
- sed -i "s/^\(${key}=.*\)\\${value};/\1/" "${file}"
+ # remove the *.scad pattern from the OpenSCAD file type.
+ sed -i "s/^\(${key}=.*\)\\${value};/\1/" "${file}"
- # if the OpenSCAD file type has no other patterns,
- # remove it and its entry in the Script group.
- if [ -z "`grep "^${key}=.+" "${file}"`" ] ; then
- sed -i "/^${key}=/d" "${file}"
- sed -i "s/^\(${category}=.*\)${key};\(.*\)$/\1\2/" "${file}"
- fi
+ # if the OpenSCAD file type has no other patterns,
+ # remove it and its entry in the Script group.
+ if [ -z "`grep "^${key}=.+" "${file}"`" ] ; then
+ sed -i "/^${key}=/d" "${file}"
+ sed -i "s/^\(${category}=.*\)${key};\(.*\)$/\1\2/" "${file}"
+ fi
}