View Single Post
Old May 20th, 2005, 2:35 PM   #4
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4 mackenga is on a distinguished road
The problem is that the redirect on the loop redirects input to anything in the loop that reads input, not just what you wanted it to. You need to rephrase this loop so that you don't need to redirect on the loop statement; do a priming read and another read within the loop, say. Or,

#!/bin/bash

[ -f "download.list" ] || exit 1

for line in `cat download.list`; do
        URL=${LINE#*,}
        TITLE=${LINE%,*}
        echo "Download $TITLE [y/n]: "
        read RESPONSE

        if [ $RESPONSE = 'y' ]; then
               echo "curl -O $URL"
        fi

done

As usual, my example code is untested; forgive me if it's a brainfart.
mackenga is offline   Reply With Quote