From: <no...@so...> - 2002-08-21 14:05:54
|
Bugs item #576373, was opened at 2002-07-02 06:46 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104664&aid=576373&group_id=4664 Category: None Group: None Status: Closed Resolution: Fixed Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Hans-Bernhard Broeker (broeker) Summary: /tmp/cscope21294.2: file already exists Initial Comment: From the menu: Find this C symbol: FOO Then we view the return values for this and want to refine the list so we go to the menu item: Find this egrep pattern: Here we type: ^ We go to the bottom of the screen and type: Pipe to shell command: grep BAR at this point we hit return and get the following message: ksh: /tmp/cscope21294.2: file already exists Press the RETURN key to continue: ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2002-08-21 07:05 Message: Logged In: NO The noclobber option should not affect the way a tool works is my point. No other tools that are coded for our Unix environment suffer from the use of noclobber. The tools provided with the OS and the tools developed here internally all function correctly and have no issue with the noclobber option. I may have not been correct with my solution (which will work in many cases) but the problem that was identified is correct. cscope should not have problems working in a kshell environment with a valid environment option turned on. Many many times have I done my self and seen in other code the use of "unlink" to remove a file before opening the file handle for writing. Also, many languages like Perl support an open that clobber regardless of the kshell noclobber setting? In other words, I don't need to remove or unlink the file before I open the file handle to write. I am confident that perl is not the only language that behaves in this manner. As far as the traditions of Unix and C not removing or unlinking files before re-populating them with new contents, I guess we have seen different traditions. Still, I appreciate your work and hope that we can stop the arguing and concentrate on the positive action of your correction of the problem. I do appreciate your efforts. Thanks, Shannon ---------------------------------------------------------------------- Comment By: Darryl Okahata (darrylo) Date: 2002-08-21 06:53 Message: Logged In: YES user_id=27401 > I suspect this to be a problem specific to ksh, or your > operating system setup. At the point of that error, cscope > is executing the following command via libc function > popen(): > > grep BAR > /tmp/cscope21294.2 Since cscope is generating "/tmp/cscope21294.2", I don't see why cscope could not just attempt to unlink this file before executing the popen(). It's a trivial change. It's not as if we'd have to perform brain sugery. -- Darryl ---------------------------------------------------------------------- Comment By: Hans-Bernhard Broeker (broeker) Date: 2002-08-21 06:33 Message: Logged In: YES user_id=27517 I'm not saying this particular way of configuring ksh is "wrong". I just consider it a poor choice, as fars as non-interactive shells are considered. The noclobber option is quite certainly a useful thing to have in interactive shells, in order to avoid accidental file overwrites by the user. But for a non-interactive shell started and controlled by some other program, it's pointless --- or worse. The effectivity of such a delete-before-write procedure is quite limited, too, in a multi-tasking environment. There's always the chance that some other process wins the race and recreates the same file before you can open it for writing. Furthermore, it will help *only* for files about to be overwritten accidentally by shell redirection, in shell scripts that don't turn off noclobber locally nor select a different shell to run in (#!/bin/sh). It will not help at all against the majority of other accidental overwrites, including redirection in other scripting languages. On top of that your experience about better deleting a file before recreating it from scratch is quite strongly at odds with all Unix and C programming traditions as I understand them. You're effectively arguing against the defined behaviour of ANSI/ISO Standard C function call fopen("filename","w"), and it's POSIX counterpart creat(..) / open (..., O_TRUNC). ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2002-08-20 11:14 Message: Logged In: NO Thanks for the new release, but..... I am not trying to offend anyone but I must take issue with the release note for this bug. You comment in the 15.4 release notes: (2002/07/07 - broeker) Delete tempfile before redirecting to it, to avoid complaints about clobbering from poorly configured default shells. This is not correct. This was not because of "poorly configured default shells" but rather the Kshell environment is purposefully setup this way to prevent developers from clobbering files in their environment. Its been my experience that a developer should remove a file before writing to it with the intention of creating new contents. If it was the developer's intention to append to the file, then they wouldn't want it removed. We are not appending in this case. It sounds as if you think this is some kind of bug or misconfigured environment. This environment option is purposeful and desireable. The question would be, is it a problem that the tool didn't work in Korn Shell, and if not, is there documentation stating that Korn Shell cannot be used with the noclobber option on? Getting back to my praise for your work: Thanks for the new release. We are looking forward to the new enhancements/fixes. Shannon ---------------------------------------------------------------------- Comment By: Hans-Bernhard Broeker (broeker) Date: 2002-08-20 10:53 Message: Logged In: YES user_id=27517 The patch is in the CVS sources and in the currently being released version 15.4. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2002-08-20 10:30 Message: Logged In: NO Sorry about that. I did get your previous message and I did read it. For some reason the ticket to me looked as though it had not been resolved. So is there a patch that I need to apply to take care of this or will it be a part of a future release? Again, I am sorry that I forgot about your previous message. Thanks for your support. ---------------------------------------------------------------------- Comment By: Hans-Bernhard Broeker (broeker) Date: 2002-08-20 07:06 Message: Logged In: YES user_id=27517 Hello--oh, anybody home? Did you even _read_ my previous comment before you posted your complaint? If so, I wonder how you managed to not see this: > But anyway: I'll add a remove(temp2) in the relevant place. You're bashing a dead horse. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2002-08-20 06:55 Message: Logged In: NO So will there be no action on this item. I think that a lot of people use the noclobber option and that this is actually a bug in cscope. Csope should remove a temp file before trying to write to it don't ya think? If there are no coding changes planned then I think something needs to be added to the documentation that says for K shell users, don't use noclobber. Right? ---------------------------------------------------------------------- Comment By: Hans-Bernhard Broeker (broeker) Date: 2002-07-08 08:52 Message: Logged In: YES user_id=27517 The "proper" setup, IMHO, would still be to have set +o clobber in whatever startup file it is that KSH reads only for *interactive* shells, with a user at the keyboard prone to typing errors that this option is meant to catch. And equivalently set +o noclobber for non-interactive shells. The flexibility to differentiate between the two case is there -- use it. I guess you'll fall into lots of similar traps using your current setup. But anyway: I'll add a remove(temp2) in the relevant place. ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2002-07-08 06:36 Message: Logged In: NO Setting the following in our initialization files (.kshrc) allowed us to work properly: set +o noclobber But, after talking to the developers that I support, we agree that we would all want to keep the set -o noclobber in tact if possible. Can the /temp/cscope21294.2 file be removed prior to writing to it? This seems to me to be the best solution for this problem. That way, developers get to keep their noclobber settings and cscope will execute the shell command as expected. Let me know your feelings on this. Thanks, for getting back with us so quickly. Shannon ---------------------------------------------------------------------- Comment By: Hans-Bernhard Broeker (broeker) Date: 2002-07-04 03:25 Message: Logged In: YES user_id=27517 I suspect this to be a problem specific to ksh, or your operating system setup. At the point of that error, cscope is executing the following command via libc function popen(): grep BAR > /tmp/cscope21294.2 Your default shell, ksh, seems to be refusing to overwrite a file using ">" redirection, which may be a useful guard against accidents in *interactive* shells --- but not when run from another process, as is the case here. In other words: please check your ksh setup, and disable the "noclobber" option for non-interactive shells. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104664&aid=576373&group_id=4664 |