Fix run_for hanging, XML escaping on bash 3.2, and step's name clash
run_for stopped dns-sd with INT, which bash ignores in background jobs
started from a script, so it never returned. It uses TERM now.
xml_escape's ${s//&/\&} keeps the backslash on bash 3.2; it uses sed
now, in all three copies.
10-core.sh's step() replaced the smoketest runner's step(); it's
core_step now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5fd4fa5a98
commit
476237366a
@@ -418,7 +418,7 @@ setup_element() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Run a step unless it's done; a failed step doesn't stop the ones after it
|
# Run a step unless it's done; a failed step doesn't stop the ones after it
|
||||||
step() {
|
core_step() {
|
||||||
local name="$1" title="$2"
|
local name="$1" title="$2"
|
||||||
if "${name}_done"; then
|
if "${name}_done"; then
|
||||||
echo " $title: already set up"
|
echo " $title: already set up"
|
||||||
@@ -458,18 +458,18 @@ setup_core() {
|
|||||||
save_conf
|
save_conf
|
||||||
|
|
||||||
echo
|
echo
|
||||||
step superpanel "Superpanel in your applications"
|
core_step superpanel "Superpanel in your applications"
|
||||||
if accounts_done; then
|
if accounts_done; then
|
||||||
echo " Mail, Calendar and Contacts: already set up"
|
echo " Mail, Calendar and Contacts: already set up"
|
||||||
else
|
else
|
||||||
setup_accounts || { echo "${RED}Mail, Calendar and Contacts were not set up.$RESET"; STATUS=1; }
|
setup_accounts || { echo "${RED}Mail, Calendar and Contacts were not set up.$RESET"; STATUS=1; }
|
||||||
fi
|
fi
|
||||||
step files "Your Nextcloud files in Finder"
|
core_step files "Your Nextcloud files in Finder"
|
||||||
if [ "$CORE_DOMAIN" = "$MAIN_DOMAIN" ]; then
|
if [ "$CORE_DOMAIN" = "$MAIN_DOMAIN" ]; then
|
||||||
if ! element_installed; then
|
if ! element_installed; then
|
||||||
app_ensure element "It's the app for your Core's chat (Matrix)." || true
|
app_ensure element "It's the app for your Core's chat (Matrix)." || true
|
||||||
fi
|
fi
|
||||||
element_installed && step element "Element with your Core's Matrix server"
|
element_installed && core_step element "Element with your Core's Matrix server"
|
||||||
fi
|
fi
|
||||||
forget_passwords
|
forget_passwords
|
||||||
return $STATUS
|
return $STATUS
|
||||||
|
|||||||
@@ -166,11 +166,9 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
xml_escape() {
|
xml_escape() {
|
||||||
local s="$1"
|
# sed, not ${s//&/\&}: bash 3.2 keeps that backslash
|
||||||
s="${s//&/\&}"
|
printf '%s' "$1" | sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g' \
|
||||||
s="${s//</\<}"
|
-e 's/"/\"/g'
|
||||||
s="${s//>/\>}"
|
|
||||||
printf '%s' "$s"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Stop the daily backup and remove the app and the job
|
# Stop the daily backup and remove the app and the job
|
||||||
|
|||||||
@@ -65,11 +65,9 @@ remove_job() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
xml_escape() {
|
xml_escape() {
|
||||||
local s="$1"
|
# sed, not ${s//&/\&}: bash 3.2 keeps that backslash
|
||||||
s="${s//&/\&}"
|
printf '%s' "$1" | sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g' \
|
||||||
s="${s//</\<}"
|
-e 's/"/\"/g'
|
||||||
s="${s//>/\>}"
|
|
||||||
printf '%s' "$s"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Mount smb://[user@]host[/share] and record what was mounted. Without a
|
# Mount smb://[user@]host[/share] and record what was mounted. Without a
|
||||||
|
|||||||
@@ -8,14 +8,16 @@
|
|||||||
# stopped, and macOS has no timeout command, so run_for stops it.
|
# stopped, and macOS has no timeout command, so run_for stops it.
|
||||||
|
|
||||||
# run_for <seconds> <command> [args]: run the command, and stop it after that
|
# run_for <seconds> <command> [args]: run the command, and stop it after that
|
||||||
# many seconds
|
# many seconds. It's stopped with TERM, not INT: bash starts background jobs
|
||||||
|
# in a script with SIGINT ignored, so INT would leave it running and wait
|
||||||
|
# would never return.
|
||||||
run_for() {
|
run_for() {
|
||||||
local seconds="$1" pid
|
local seconds="$1" pid
|
||||||
shift
|
shift
|
||||||
"$@" &
|
"$@" &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep "$seconds"
|
sleep "$seconds"
|
||||||
kill -INT "$pid" 2> /dev/null
|
kill -TERM "$pid" 2> /dev/null
|
||||||
wait "$pid" 2> /dev/null
|
wait "$pid" 2> /dev/null
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,9 @@
|
|||||||
PROFILES_PANE="x-apple.systempreferences:com.apple.Profiles-Settings.extension"
|
PROFILES_PANE="x-apple.systempreferences:com.apple.Profiles-Settings.extension"
|
||||||
|
|
||||||
xml_escape() {
|
xml_escape() {
|
||||||
local s="$1"
|
# sed, not ${s//&/\&}: bash 3.2 keeps that backslash
|
||||||
s="${s//&/\&}"
|
printf '%s' "$1" | sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g' \
|
||||||
s="${s//</\<}"
|
-e 's/"/\"/g'
|
||||||
s="${s//>/\>}"
|
|
||||||
s="${s//\"/\"}"
|
|
||||||
printf '%s' "$s"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# The same UUID each time for the same name, so a payload is the same account
|
# The same UUID each time for the same name, so a payload is the same account
|
||||||
|
|||||||
Reference in New Issue
Block a user