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

 
 

bug #20245: bad variable substitution?

Submitted by:  Miguel Ángel <slap>
Submitted on:  Sat 23 Jun 2007 03:29:44 PM UTC  
 
Category: findSeverity: 3 - Normal
Item Group: NoneStatus: Invalid
Privacy: PublicAssigned to: Bob Proulx <rwp>
Originator Name: slapOpen/Closed: Closed
Release: 4.2.28Fixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

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>
Project MemberIn charge of this item.
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 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 (Updated the item)
  • -unavailable- added by rwp (Posted a comment)
  • -unavailable- added by slap (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
    Fri 05 Sep 2008 08:45:38 AM UTCjayStatusNone=>Invalid
    Sat 23 Jun 2007 03:52:16 PM UTCrwpAssigned toNone=>rwp
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1