bugfindutils - Bugs: bug #20245, bad variable substitution?

 
 

bug #20245: bad variable substitution?

Submitter:  Miguel Ángel <slap>
Submitted:  Sat 23 Jun 2007 03:29:44 PM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  rwp
Originator Name:  slap Open/Closed:  Closed
Release:  4.2.28 Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 23 Jun 2007 04:18:45 PM UTC, comment #2: 

Yes, adding eval before the find command works!

Thank's

Miguel Ángel <slap>
Sat 23 Jun 2007 03:52:16 PM UTC, comment #1: 

The problem you have experienced is not a bug in find but is due to  insufficient evaluation of quoted arguments.  This can be seen by using 'sh -x' to invoke your test script.

  mask="-name '$2'"
  find $1 $mask -type f -print

  $ sh -x ./script '*txt'
  + mask='-name '\''*txt'\'''
  + find . -name ''\''*txt'\''' -type f -print

The find program is receiving the quote characters.  In your example the find command needs a shell 'eval' in order to remove one layer of shell quoting.

  mask="-name '$2'"
  eval find $1 $mask -type f -print

I hope this helps.  If it does not resolve your issue then please post again.  Thanks.

Bob Proulx <rwp>
Group Member
Sat 23 Jun 2007 03:29:44 PM UTC, original submission:  

Hello, I've written a script that performs something like this:

mask="-name '$2'"

find $1 $mask -type f -print0

When I invoke the script this way:

./script . "*txt"

There is no output (thought there are *txt files into directory .)

Is this a bug?

Thank's in advance.

Miguel Ángel <slap>

 

(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 (Updated the item)
  • -email is unavailable- added by rwp (Posted a comment)
  • -email is unavailable- added by slap (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
    2008-09-05 jay StatusNone Invalid
    2007-06-23 rwp Assigned toNone rwp
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code