Mail Archives: cygwin/2008/07/23/16:01:25
"Buchbinder, Barry" wrote:
> Wilfried wrote on Monday, July 21, 2008 10:11 AM:
>
> > Ehh, I just saw that Rodrigo Medina addressed all these problems.
> >
> > So the script would probably look like this:
> >
> > --------------snip-------------
> > #!/bin/sh
> > $1 $2 $3 $4 $5 | unix2dos > tmp_file
> > cygstart notepad.exe /p tmp_file
> > rm tmp_file
> > --------------snip-------------
>
> It looks to me that the command
> $1 $2 $3 $4 $5
> has two or three problems:
> (1) Arguments are not quoted.
> (2) One might have more than a command and 4 arguments.
> (3) It is also possible that one may have surprises if /bin/sh is set up so when non-interactive it handles aliases and shell functions differently than expected.
> So I would just pipe into the shell script.
>
> The second place is that there is theoretically a race between cygstart and rm. What happens if rm deleted tmp_file before notepad reads it? I can think of two ways to handle it. Adding
> sleep 1
> to delay rm by a second will probably usually be enough of a delay. Substituting
> "$(cygpath -u "$COMSPEC")" /c start /wait notepad.exe /p tmp_file
> for
> cygstart notepad.exe /p tmp_file
> to use Windows' start command will wait until notepad is closed. (This may be longer than you want to wait.)
>
> But I haven't tried this, so it may not work.
>
> --------------snip--------------
> #!/bin/sh
> unix2dos > tmp_file
> cygstart notepad.exe /p tmp_file
> sleep 1
> rm tmp_file
> --------------snip--------------
Thanks for the discussion.
I had tested my script and it worked for me.
I agree that just 5 parameters may be not enough.
But there is no need to put the sleep command in.
I had the impression that the script waited until the cygstart command
was finished. But even if not -- Notepad loads the file completely into
memory and then releases the file handle, so one can delete the file
while notepad is still open.
Regards, Wilfried
--
Wilfried Hennings
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -