systemd/postmarketos-base-systemd: fix handling of added and removed units in trigger
Apparently the eval trick doesn't work for passing vars if the var to set is the same as the var for the value, in this case the caller of this function was using `added_paths` and `removed_paths`. Shell scripts suck. This was missed in the tests because the unit tests call trigger_unit_presets directly. Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/7025>
This commit is contained in:
parent
5c01db2b90
commit
2a4d4f8b61
2 changed files with 9 additions and 7 deletions
|
|
@ -113,5 +113,5 @@ e49972d276441e9da284315bab5f70d8d25ccba5e43d7e7ec6607c34a3d4dfa512f7303d5ce41076
|
|||
93ab180810dbd2a1477f7ea0f0959be90f099272fe5840030a0772771c97a066b70068c476d32c6a4610b8f7b9fc5bfcf1d7a93f071cec026553ac6a3b8b5324 rootfs-usr-lib-systemd-resolved.conf.d-disable-mdns.conf
|
||||
6ff3fbd88493e50de5821c6e3db92623b38de52be4e8e967f4f297d8f70e31a86d91f1243b973387b80c8520edcc89a8233db6f234bca22a56ee61a1b4333670 rootfs-etc-apk-commit_hooks.d-postmarketos-base-systemd
|
||||
605df1f004783d2e0ec5dd99a688bca27502c8c24bc05fb4dc26589b2070b0fbd1cf9bd56e6861d7cda2f8ac8147e7eb040acfd886185c01c8cf9de8b1ce2dcd rootfs-usr-bin-setup-timezone
|
||||
450c9a67837c273372807370cf10886f338b7e95a8732f41e62e49b4f882abb7c97e122c2b84a7647eb32638e4eb278005c0d6120e0508e60af818a5659fbd7e rootfs-usr-libexec-systemd-apk-trigger
|
||||
d96898efb28508b172f148c0a468a7dddd363dde94efea7c2274b9f746544b4e8bf7905ce3f8134a97c1eb33210ad97380f3da452082f346f1f3f0f665f79d47 rootfs-usr-libexec-systemd-apk-trigger
|
||||
"
|
||||
|
|
|
|||
|
|
@ -62,8 +62,10 @@ parse_diff_output() {
|
|||
local diff_output="$1"
|
||||
local added_var="$2"
|
||||
local removed_var="$3"
|
||||
local added_paths=""
|
||||
local removed_paths=""
|
||||
# Note: use an underscore here to reduce the chances that $added_var and
|
||||
# $removed_car are set to the variable names here:
|
||||
local _added_paths=""
|
||||
local _removed_paths=""
|
||||
|
||||
# Using heredoc to process lines and avoid a subshell, see SC2031
|
||||
while IFS= read -r line; do
|
||||
|
|
@ -74,10 +76,10 @@ parse_diff_output() {
|
|||
# Skip directories
|
||||
continue;;
|
||||
-[!-]*)
|
||||
removed_paths="$removed_paths $path"
|
||||
_removed_paths="$_removed_paths $path"
|
||||
;;
|
||||
+[!+]*)
|
||||
added_paths="$added_paths $path"
|
||||
_added_paths="$_added_paths $path"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
|
|
@ -87,8 +89,8 @@ parse_diff_output() {
|
|||
EOF
|
||||
|
||||
# Set results in caller's variables
|
||||
if [ -n "$added_var" ]; then eval "$added_var=\"$added_paths\""; fi
|
||||
if [ -n "$removed_var" ]; then eval "$removed_var=\"$removed_paths\""; fi
|
||||
if [ -n "$added_var" ]; then eval "$added_var=\"$_added_paths\""; fi
|
||||
if [ -n "$removed_var" ]; then eval "$removed_var=\"$_removed_paths\""; fi
|
||||
}
|
||||
|
||||
run_systemctl() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue