On 06/14/2010 06:18 PM, Mike Miller wrote:
> Have you run into this problem before?  I have one script calling a second
> script.  The second script contains this code:
>
> if [ -e index.html ]; then
>      echo -e "\nCtrl-c to preserve old index.html and terminate processing\n"
>      echo "enter 'y' to delete index.html, or 'n' to retain the current index.html"
>      rm -i index.html
> fi
>
>
> When we get to that section, if index.html exists, this is what we see on
> the screen (I entered the 'y' that's on a line by itself):
>
> Ctrl-c to preserve old index.html and terminate processing
>
> enter 'y' to delete index.html, or 'n' to retain the current index.html
> y
> rm: remove regular empty file `index.html'?
>
>
> In other words, it does not show the prompt from "rm -i" until after the
> response has been entered.  Any ideas?  I think it has something to do
> with the fact that the script is called by another script.  If I call the
> script directly from the command line, it behaves just fine.  It would
> make more sense to me if I never saw the prompt, but it does appear, just
> a little too late.

I'm fairly certain it is because echo is printing to stdout and rm -i is 
stderr.

Try "rm -i index.html 2>&1" (redirect stderr to stdout) in your script 
to see if that changes anything. Or, "echo <blah> 1>&2 " to redirect 
stdout to stderr.

I could be wrong here, but it is a hunch.

-Jeremy