Demi Marie Obenour writes: > On 11/13/25 07:04, Alyssa Ross wrote: >> +# SPDX-License-Identifier: EUPL-1.2+ >> +# SPDX-FileCopyrightText: 2024 Alyssa Ross >> + >> +backtick -E dir { mktemp -d /run/vm/by-id/XXXXXX } >> +backtick -E id { basename -- $dir } > > Serial substitution: if $1 or $2 contains something like ${dir} or ${id} > they will be expanded again. Can be avoided with multisubstitute: > > backtick dir { mktemp -d /run/vm/by-id/XXXXXX } > backtick id { importas -iS dir basename -- $dir } > multisubstitute { > import -iS dir > import -iS id > define install_dir $1 > define app_id $2 > } > > The general rule I follow is to never substitute a parameter into > an argv that has already been substituted into. This can be done > by renaming all "variables" whenever one does a substitution. > >> +if { mkdir -p /run/configs/${id}/fs } >> +if { redirfd -w 1 /run/configs/${id}/fs/type echo flatpak } >> +if { cd /run/configs/${id}/fs mount-flatpak $1 $2 } >> +if { >> + ln -s /usr/lib/spectrum/img/appvm/blk /usr/lib/spectrum/img/appvm/vmlinux >> + /run/configs/${id} >> +} >> + >> +if { ln -s /run/configs/${id} ${dir}/config } >> + >> +if { create-vm-dependencies $id } >> + >> +piperw 4 3 >> +background { >> + fdclose 3 >> + fdmove 0 4 >> + >> + # Wait for the VMM to be up, then start the VM. >> + if { redirfd -w 1 /dev/null head -1 } >> + vm-start $id >> +} >> +fdclose 4 >> + >> +foreground { run-vmm $id } >> +fdclose 3 >> + >> +if { >> + forx -pE service { >> + dbus >> + vhost-user-fs >> + vhost-user-gpu >> + xdg-desktop-portal-spectrum-host >> + } >> + s6-instance-delete /run/service/${service} $id >> +} > > Serial substitution again. This should not be an issue: POSIX requires > mktemp to use only characters in the portable filename character set, > and $ is not in that set. An execline static analyzer would flag > this, though. > > If you want to avoid serial substitution, the usual workaround of > multisubstitute should do the job. > Minor correction: POSIX doesn't specify mktemp(1), only the library functions, but Busybox mktemp uses mkdtemp(3), which is also specified to use the portable character set.