Read the lines of your files and store them in an array (see how to do it in zsh there). After that, it is simply a matter of looping through the array and firing the desired command for each element.
# read the file (zsh-only syntax):
args=( "${(@f)$(< file.txt)}" )
# loop through its lines (sh-compatible syntax):
for arg in "${arg[@]}" ; do
"$run_program" "settings:default argument:$arg"
done
Of course if you do not need the contents of the file for anything else, you could collapse the first two lines into one and avoid naming an array to store the lines.
for arg in "${(@f)$(< file.txt)}" ; do
"$run_program" "settings:default argument:$arg"
done
Alternatively, you can read the file line by line and process these lines directly. For that, you’d use a canonical pattern which combines the read
primitive (used carefully) and a while
loop, and which is not specific to zsh.
# sh-compatible syntax:
while IFS= read -r arg || [ -n "$arg" ] ; do
"$run_program" "settings:default argument:$arg"
done < file.txt