bugfindutils - Bugs: bug #24561, find -ok should not redirect stdin

 
 

bug #24561: find -ok should not redirect stdin

Submitted by:  Eric Blake <ericb>
Submitted on:  Tue 14 Oct 2008 08:20:05 PM UTC  
 
Category: findSeverity: 3 - Normal
Item Group: Wrong resultStatus: None
Privacy: PublicAssigned to: None
Originator Name: Eric BlakeOpen/Closed: Open
Release: 4.2.12Fixed Release: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Thu 07 Oct 2010 09:48:00 AM UTC, comment #6:

Updating the state of the bug since I don't think it's blocking on a response from the original reporter.

James Youngman <jay>
Project Administrator
Mon 12 Apr 2010 04:22:30 PM UTC, comment #5:

I haven't had as much time for findutils lately as I had hoped, so if you beat me to it, I won't mind. I'm still undecided on whether -okdir should behave the same as the (eventually) fixed -ok or keep its current semantics of redirecting stdin from /dev/null.

Eric Blake <ericb>
Project Administrator
Sun 11 Apr 2010 11:45:48 AM UTC, comment #4:

Eric, are you hoping to work on this yourself, or should I take a closer look?

James Youngman <jay>
Project Administrator
Sun 09 Nov 2008 12:09:32 PM UTC, comment #3:

Should we for whatever reason decide not to change the code, -unavailable- suggests an example:

JY> If you would like to propose an illustrative problem for which
JY> your workaround is the most effective solution, we can probably
JY> include that in the documentation as an example.

OK, please mention something like:
-ok in contrast to -exec, has its stdin redirected for various reasons.
To workaround this, where one would normally use -ok, one should use e.g.,
-ok true \; -exec ed {} \; #to edit selected files
-ok true \; -exec mplayer {} \; #to play selected songs

James Youngman <jay>
Project Administrator
Sat 08 Nov 2008 02:57:55 PM UTC, comment #2:

If we're not complying with POSIX, then we do need to fix this. The problem appears to affect all versions of findutils since 4.2.12.

Eric, would you like to make a patch?

If the user does want stdin redirected, they can always use the shell trick:

find .... -ok sh -c 'foo --args "$@" </dev/null' x {} \;

James Youngman <jay>
Project Administrator
Tue 14 Oct 2008 08:33:35 PM UTC, comment #1:

Note, however, that -okdir remains a GNU extension, and that as such, it should probably continue redirecting stdin from /dev/null (since we can claim, as part of providing the extension, that it is more predictable if child processes can't interfere with our ability to ask which commands to run).

Eric Blake <ericb>
Project Administrator
Tue 14 Oct 2008 08:20:05 PM UTC, original submission:

http://lists.gnu.org/archive/html/bug-findutils/2008-10/msg00003.html

According to POSIX, -ok is supposed to be like -exec, except for the fact that it prompts and read stdin. By that interpretation, it is a bug that find redirects stdin of the child process of -ok from /dev/null; it should let the child see the same stdin. If find's stdin is not seekable (such as a pipe), then behavior is already unspecified; so it is okay for find to continue using stdio to read prompts, as long as it resets the seekable fd back to the newline that ended the response to the prompt, even though this means that child processes will inherit piped stdin in an unknown state.

Eric Blake <ericb>
Project Administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jay (Posted a comment)
  • -unavailable- added by ericb (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 07 Oct 2010 09:48:00 AM UTCjayStatusNeed Info=>None
    Sun 11 Apr 2010 11:45:48 AM UTCjayStatusNone=>Need Info
    Sat 08 Nov 2008 02:57:55 PM UTCjayRelease4.5.2=>4.2.12

    Back to the top


    Powered by Savane 3.1-cleanup