Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Wed, 19 Nov 2003 12:55:20 -0500 (EST) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: alan DOT miles AT ieee DOT org cc: cygwin AT cygwin DOT com Subject: RE: Diff for generic readme and generic-build script In-Reply-To: Message-ID: References: Importance: Normal MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Alan, The bug with 'sed -i' was that if it's unable to write to (or, rather, "creat") "/tmp/sedGARBAGE", it assumes that the file exists and tries another name ("/tmp/sedMOREGARBAGE"), and so on (in a loop). If /tmp is not writeable at all, sed will loop indefinitely. As long as your script checks only once (and redirection is usually better at handling existing files, since you never claimed your script is reentrant), you should be ok. You can simply replace "${ThePackageReadMeFile}.tmp" in your patch with "/tmp/${ThePackageReadMeFile}.tmp" (or even "`mktemp -t "${ThePackageReadMeFile}.XXXXXX"`", but you'd need to store that in a variable). Igor On Tue, 18 Nov 2003, Alan Miles wrote: > Igor, > > With this change I discovered a very subtle problem - the files listed will > show two entries instead of one for the README: > > /usr/share/doc/Cygwin/%PKG%.README > /usr/share/doc/Cygwin/%PKG%.README.tmp > > This is due to the way where I redirected the file to. > > There are two solutions: > 1/ Put the redirected temp file under /tmp, i.e., /tmp/%PKG%.README and then > doing a 'mv -f /tmp/%PKG%.README /usr/share/doc/Cygwin/%PKG%.README'. The > listing won't be affected since before and after will contain the same file > name. > > 2/ Adjusting the find command to filter-out the > /usr/share/doc/Cygwin/%PKG%.README.tmp file in its listing. > > Which solution would be your preference? (Unless you have another one of > course ...) > > Alan > > -----Original Message----- > From: Alan Miles [mailto:miles0201 AT cox DOT net] > Sent: November 18, 2003 19:05 > To: cygwin AT cygwin DOT com > Subject: RE: Diff for generic readme and generic-build script > > > Igor, > > Fixed the script patch as per your comment about -i. The `e [COMMAND]' is > still valid, as replacing it with 'r -' did not work. > > Alan > -----Original Message----- > From: Igor Pechtchanski [mailto:pechtcha AT cs DOT nyu DOT edu] > Sent: November 18, 2003 13:02 > To: alan DOT miles AT ieee DOT org > Cc: cygwin AT cygwin DOT com > Subject: Re: Diff for generic readme and generic-build script > > > On Mon, 17 Nov 2003, Alan Miles wrote: > > > [snip] > > 7/ Note: the -i option to sed (quoting the man page for sed): > > > > -i[suffix], --in-place[=suffix] > > edit files in place (makes backup if extension supplied) > > > > Extended sed command: > > > > `e [COMMAND]' > > This command allows one to pipe input from a shell command into > > pattern space. Without parameters, the `e' command executes the > > command that is found in pattern space and replaces the pattern > > space with the output; a trailing new-line is suppressed. > > > > If a parameter is specified, instead, the `e' command interprets > > it as a command and sends it to the output stream (like `r' does). > > The command can run across multiple lines, all but the last > > ending with a back-slash. > > > > In both cases, the results are undefined if the command to be > > executed contains a NUL character. > > > > These together constitute the operation of the modifications. > > Note: the -i option to sed is buggy, as it will go into an infinite loop > if /tmp is not writable (which does happen occasionally with Cygwin). > It's better to use explicit redirection and renaming instead. > Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "I have since come to realize that being between your mentor and his route to the bathroom is a major career booster." -- Patrick Naughton -- 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/