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

 
 

bug #24561: find -ok should not redirect stdin

Submitter:  Eric Blake <ericb>
Submitted:  Tue 14 Oct 2008 08:20:05 PM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  Wrong result Status:  None
Privacy:  Public Assigned to:  None
Originator Name:  Eric Blake Open/Closed:  Open
Release:  4.2.12 Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 01 Sep 2019 08:51:11 AM UTC, comment #7: 

I would suggest that -okdir should follow -ok unless there turn out to be some very user-surprising consequences.

James Youngman <jay>
Group administrator
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>
Group 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>
Group 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>
Group administrator
Sun 09 Nov 2008 12:09:32 PM UTC, comment #3: 

Should we for whatever reason decide not to change the code, -email is 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>
Group 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>
Group 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>
Group 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>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-10-07 jay StatusNeed Info None
    2010-04-11 jay StatusNone Need Info
    2008-11-08 jay Release4.5.2 4.2.12

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code