bugfindutils - Bugs: bug #26217, argument parsing bug with -regex...

 
 

bug #26217: argument parsing bug with -regex .... \; without preceding -exec

Submitter:  None
Submitted:  Fri 17 Apr 2009 09:07:10 PM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  Wrong result Status:  Invalid
Privacy:  Public Assigned to:  jay
Originator Name:  dan pritts Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  4.4.0
Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 31 Mar 2010 07:42:24 AM UTC, comment #4: 

The error message is different in 4.5.6b

$ ./find/find /home/mysql/olddbroots -ls ';'
./find/find: paths must precede expression: ;
Usage: ./find/find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

James Youngman <jay>
Group administrator
Mon 20 Apr 2009 06:04:36 PM UTC, comment #3: 

It's probably sufficiently useful to change the existing error message to display the unexpected extra argument.

James Youngman <jay>
Group administrator
Mon 20 Apr 2009 01:39:31 PM UTC, comment #2: 

Damn, I knew I must be doing something dumb, sorry.

Now that I know what it means, the error message is clear, but the eye just skipped past the : ; combo.

Might I suggest a special-case error message when an unnecessary trailing ; is encountered?

thanks!

dan pritts <danpritts>
Fri 17 Apr 2009 10:43:53 PM UTC, comment #1: 

Thanks for the detailed bug report.  However, many of the options you used make no difference to the problem.  You can reduce it to this case:

$ find /home/mysql/olddbroots     -ls ';'
find: paths must precede expression: ;
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

The problem is that the directory/file start points need to be specified before the tests on the command line.  Since ";" does not begin with "-" it is assumed to be a start point rather than a test, but start points don't belong at that position in the command line.   In other words, just remove the \;.  The only reason you need to use \; in the -exec case is that the \; marks the end of the arguments to -exec.

James Youngman <jay>
Group administrator
Fri 17 Apr 2009 09:07:10 PM UTC, original submission:  

Apologies if this is some sort of stupidity on my part but I've poked at this and read the docs a bunch.

my os is RHEL5, 32-bit x86.  I've built my own findutils 4.4.0 to confirm it's not just in RHEL's find.

Consider these two commands; they should be the same other than the final line.


/home/danno/src/findutils-4.4.0/find/find $OLDDBROOTDIR \
   -regextype posix-extended \
   -maxdepth 1 \
   -type d \
   -regex "${OLDDBROOTDIR}/dbroot-[0-9]{8}-[0-9]{6}" \
   -mtime +${num_days} \
   -exec /bin/ls {} \;


/home/danno/src/findutils-4.4.0/find/find $OLDDBROOTDIR \
   -regextype posix-extended \
   -maxdepth 1 \
   -type d \
   -regex "${OLDDBROOTDIR}/dbroot-[0-9]{8}-[0-9]{6}" \
   -mtime +${num_days} \
   -ls \;


Here's what I get when i execute the script that contins them:


exec /bin/ls:
+ /home/danno/src/findutils-4.4.0/find/find /home/mysql/olddbroots -regextype posix-extended -maxdepth 1 -type d -regex '/home/mysql/olddbroots/dbroot-[0-9]{8}-[0-9]{6}' -mtime +20 -exec /bin/ls '{}' ';'

[empty result is expected]


find -ls:
+ /home/danno/src/findutils-4.4.0/find/find /home/mysql/olddbroots -regextype posix-extended -maxdepth 1 -type d -regex '/home/mysql/olddbroots/dbroot-[0-9]{8}-[0-9]{6}' -mtime +20 -ls ';'

/home/danno/src/findutils-4.4.0/find/find: paths must precede expression: ;
Usage: /home/danno/src/findutils-4.4.0/find/find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

[error message is not expected]

in general, if i give -exec, the command succeeds; if i try -print or -ls or just leave it out, it fails. 

The directory i'm specifying (/home/mysql/olddbroots) does exist.

Anonymous

 

(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 danpritts (Posted a comment)
  • -email is unavailable- added by jay (Posted a comment)
  • -email is unavailable- added by None (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-03-31 jay Assigned toNone jay
        Open/ClosedOpen Closed
        Summaryargument parsing bug with -regex .... \\; without preceding -exec argument parsing bug with -regex .... \; without preceding -exec
    2009-04-20 jay Summaryargument parsing bug with -regex .... \\; without preceding -exec argument parsing bug with -regex .... \; without preceding -exec
    2009-04-17 jay StatusNone Invalid
        Summaryargument parsing bug with -regex argument parsing bug with -regex .... \; without preceding -exec

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code