docker-library / busybox

Docker Official Image packaging for Busybox

Home Page:http://busybox.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

confused by for loop

zffocussss opened this issue · comments

https://github.com/docker-library/busybox/blob/164603caaa94899332207e45ca06c1b467108851/apply-templates.sh#L32C1-L50C5

for version; do
....
done

can some guys tell me how this block work,as version is not a array variables.

That is shorthand for the following:

for version in "$@"; do

i.e. looping over the args to the script. When the args list is empty in this script, it is set by the eval "set -- $versions" of this block:

if [ "$#" -eq 0 ]; then
versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)"
eval "set -- $versions"
fi

it is so interesting,can you please give me a link to this syntax,as I never used/known about it.

what is this meaning ? ${dir////-}

for dir; do
	base="busybox:${dir////-}"
done

it is so interesting,can you please give me a link to this syntax,as I never used/known about it.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04_03

what is this meaning ? ${dir////-}

https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion (specifically, ${parameter//pattern/string} - replace all / with -)

it is so interesting,can you please give me a link to this syntax,as I never used/known about it.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_04_03

what is this meaning ? ${dir////-}

https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion (specifically, ${parameter//pattern/string} - replace all / with -)

it do work,thanks @tianon