Loop terminal command for combining PNG to GIF animation [duplicate]

If I understand correctly, if you have mypgrogram that outputs the list of filenames, you should be able to simply do

convert -delay 10 -loop 0 $(myprogram) animation.gif

The $(...) operator is a bash shell operation that runs the indicated command and then replaces itself with the output (more or less... the shell is a quite powerful tool).