sanebox: avert a subshell in removeSubpaths

This commit is contained in:
2024-05-18 08:07:26 +00:00
parent 3361f2bbe7
commit 6365a58c3e

View File

@@ -887,7 +887,7 @@ removeSubpaths() {
for path in "${paths[@]}"; do
local isSubpath=
for other in "${paths[@]}"; do
if [[ "$path" =~ ^"$other"/ ]] || ( [ "$other" = / ] && [ "$path" != / ] ); then
if [[ "$path" =~ ^"$other"/ ]] || [ "$other" = / -a "$path" != / ]; then
# N.B.: $path lacks a trailing slash, so this never matches self.
# UNLESS $path or $other is exactly `/`, which we special-case.
isSubpath=1