bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with open and rm


From: Greg Wooledge
Subject: Re: Problem with open and rm
Date: Wed, 16 Mar 2011 14:42:13 -0400
User-agent: Mutt/1.4.2.3i

On Wed, Mar 16, 2011 at 10:54:15AM +0000, Barrie Stott wrote:
> The script that follows is a cut down version of one that came from elsewhere.
> 
> #!/bin/bash
> 
> cp /tmp/x.html /tmp/$$.html
> ls /tmp/$$.html
> [ "$DISPLAY" ] && open /tmp/$$.html
> ls /tmp/$$.html
> rm -f /tmp/$$.html

> If I comment out the final 'rm' line and run it again, I get what I want
> displayed (and a similar pair of lines on the terminal) but unfortunately the
> temporary file is left lying around.

My guess would be that "open" sends a message to some other process (or
creates a child process of its own, and detaches it), which takes some
time to process the file.  If you rm it before open gets a chance to
process it, you get the "No such file" message.

As a cheap workaround, you can just delay the rm a bit.  Add a sleep
command before it.

A proper fix would be for open to allow you some means of finding out
when it has, in fact, "opened" the target, so that you know when it's
safe to remove it.  I doubt you'll be able to do that, but hey, maybe
I'm wrong.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]