How to port to bash-style arrays to ash?

Before arrays were in bash, ksh, and other shells, the usual method was to pick a delimiter that wasn't in any of the elements (or one that was uncommon to minimise any required escaping), and iterate over a string containing all the elements, separated by that delimiter. Whitespace is usually the most convenient delimiter choice because the shell already splits "words" by whitespace by default (you can set IFS if you want it to split on something different).

For example:

# backslash-escape any non-delimiter whitespace and all other characters that
# have special meaning to the shell, e.g. globs, parenthesis, ampersands, etc.
services='service1.service service2.service service3.service'

for s in $services ; do  # NOTE: do not double-quote $services here.
  START "$s"
done

$services should NOT be double-quoted here because we want the shell to split it into "words".


ash does not have arrays. The only thing that comes close is the positional parameters, so you could do

set -- "service1.service" \
       "service2.service" \
       "service3.service"

for service in "$@"
do
   START $service
done

If you need to refer to the list of services only once, you can use a here-doc:

while IFS= read -r service
do
   START "$service"
done << END
service1.service
service2.service
service3.service
END

Note that the service names should not be quoted in the list (although "$service" probably should be quoted, unless you have a good reason not to).  If you would like to have the service names indented, use <<- instead of << and indent the names with tabs:

while IFS= read -r service
do
   START "$service"
done <<- END
        service1.service
        service2.service
        service3.service
END