scripts/calcurse-upgrade.sh: Fix POSIX compatibility

* Split sed(1) one-liners into multiple lines. POSIX sed(1) doesn't
  allow separating functions by semicolons.

* Escape a newline in the awk(1) script. POSIX awk(1) only allows
  non-escaped line breaks in specific contexts.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2012-06-01 12:27:06 +02:00
parent 6e490e979c
commit 0d50e4539f

View File

@ -56,28 +56,95 @@ if grep -q -e '^auto_save=' -e '^auto_gc=' -e '^periodic_save=' \
mv "$tmpfile" "$CONFFILE" mv "$tmpfile" "$CONFFILE"
if grep -q -e '^[^#=][^#=]*$' -e '^[^#=][^#=]*#.*$' "$CONFFILE"; then if grep -q -e '^[^#=][^#=]*$' -e '^[^#=][^#=]*#.*$' "$CONFFILE"; then
sed -e '/^general.autosave=/{N;s/\n//}' \ sed '
-e '/^general.autogc=/{N;s/\n//}' \ /^general.autosave=/{
-e '/^general.periodicsave=/{N;s/\n//}' \ N
-e '/^general.confirmquit=/{N;s/\n//}' \ s/\n//
-e '/^general.confirmdelete=/{N;s/\n//}' \ }
-e '/^general.systemdialogs=/{N;s/\n//}' \ /^general.autogc=/{
-e '/^general.progressbar=/{N;s/\n//}' \ N
-e '/^appearance.calendarview=/{N;s/\n//}' \ s/\n//
-e '/^general.firstdayofweek=/{N;s/\n//}' \ }
-e '/^appearance.theme=/{N;s/\n//}' \ /^general.periodicsave=/{
-e '/^appearance.layout=/{N;s/\n//}' \ N
-e '/^appearance.sidebarwidth=/{N;s/\n//}' \ s/\n//
-e '/^appearance.notifybar=/{N;s/\n//}' \ }
-e '/^format.notifydate=/{N;s/\n//}' \ /^general.confirmquit=/{
-e '/^format.notifytime=/{N;s/\n//}' \ N
-e '/^notification.warning=/{N;s/\n//}' \ s/\n//
-e '/^notification.command=/{N;s/\n//}' \ }
-e '/^notification.notifyall=/{N;s/\n//}' \ /^general.confirmdelete=/{
-e '/^format.outputdate=/{N;s/\n//}' \ N
-e '/^format.inputdate=/{N;s/\n//}' \ s/\n//
-e '/^daemon.enable=/{N;s/\n//}' \ }
-e '/^daemon.log=/{N;s/\n//}' "$CONFFILE" > "$tmpfile" /^general.systemdialogs=/{
N
s/\n//
}
/^general.progressbar=/{
N
s/\n//
}
/^appearance.calendarview=/{
N
s/\n//
}
/^general.firstdayofweek=/{
N
s/\n//
}
/^appearance.theme=/{
N
s/\n//
}
/^appearance.layout=/{
N
s/\n//
}
/^appearance.sidebarwidth=/{
N
s/\n//
}
/^appearance.notifybar=/{
N
s/\n//
}
/^format.notifydate=/{
N
s/\n//
}
/^format.notifytime=/{
N
s/\n//
}
/^notification.warning=/{
N
s/\n//
}
/^notification.command=/{
N
s/\n//
}
/^notification.notifyall=/{
N
s/\n//
}
/^format.outputdate=/{
N
s/\n//
}
/^format.inputdate=/{
N
s/\n//
}
/^daemon.enable=/{
N
s/\n//
}
/^daemon.log=/{
N
s/\n//
}' "$CONFFILE" > "$tmpfile"
mv "$tmpfile" "$CONFFILE" mv "$tmpfile" "$CONFFILE"
fi fi
@ -86,7 +153,7 @@ if grep -q -e '^auto_save=' -e '^auto_gc=' -e '^periodic_save=' \
$1 == "general.systemdialogs" || $1 == "general.progressbar" \ $1 == "general.systemdialogs" || $1 == "general.progressbar" \
{ $2 = ($2 == "yes") ? "no" : "yes" } { $2 = ($2 == "yes") ? "no" : "yes" }
$1 == "general.firstdayofweek" { $2 = ($2 == "yes") ? "monday" : "sunday" } $1 == "general.firstdayofweek" { $2 = ($2 == "yes") ? "monday" : "sunday" }
$1 == "appearance.calendarview" { $2 = ($2 == 0) ? "monthly" : $1 == "appearance.calendarview" { $2 = ($2 == 0) ? "monthly" : \
($2 == 1) ? "weekly" : $2 } ($2 == 1) ? "weekly" : $2 }
{ print } { print }
' < "$CONFFILE" > "$tmpfile" ' < "$CONFFILE" > "$tmpfile"