to whoever broke desktop-defaults-mx-common, a bit of shell advice
Posted: Mon Jan 09, 2023 9:54 am
To @delphin_oracle or whoever wrote the postinst script of desktop-defaults-mx-common, I can't reply to the announcement, so I'm posting here. Here's what that piece of... beauty (/var/lib/dpkg/info/desktop-defaults-mx-common.postinst)... looks like, and how to fix it (see "# ME:" comments):
The most important part is to NOT QUOTE:
Otherwise, the script will break on multi-user systems. Hopefully you see why.
Also, you should check with (and probably also -r) before calling sed.
Also, you don't usually save results into a variable. You use .
Also, for the future, if you're quoting a string and you DON'T want expansion, use single quotes, not double quotes.
Also, and finally, instead of you could have simply said (and obviously check with [ -w "$i" ]). This would have averted the entire problem.
To users: simply edit
Code: Select all
#! /bin/sh
set -e
if [ -x /etc/init.d/umountnfs-alternative.sh ]; then
if [ -x /usr/sbin/update-rc.d ]; then
update-rc.d umountnfs-alternative.sh remove >/dev/null 2>&1
update-rc.d umountnfs-alternative.sh defaults >/dev/null 2>&1
fi
fi
##fix mx-tools menu files (mx 21 and older)
FILES="$(find /home/ -true -wholename "*.config/menus/applications-merged/mx-tools.menu")"
if [ -n "$FILES" ]; then
for i in "$FILES"; do # ME: you want to word-split $FILES, so DON'T QUOTE!!! Your construct breaks if there are multiple users
sed -i 's/MX-Tools/mx-tools/' "$i"
done
fi
exit 0
Code: Select all
for i in $FILES; do
Also, you should check with
Code: Select all
[ -w "$i" ]
Also, you don't usually save
Code: Select all
$(find)
Code: Select all
find ... -exec ... ';'
Also, for the future, if you're quoting a string and you DON'T want expansion, use single quotes, not double quotes.
Also, and finally, instead of
Code: Select all
find -true -wholename
Code: Select all
for i in /home/*/config/menus/applications-merged/mx-tools.menu
To users: simply edit
Code: Select all
/var/lib/dpkg/info/desktop-defaults-mx-common.postinst