[Bug 592672] Review Request: hct - A HDL complexity tool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Please do not reply directly to this email. All additional
comments should be made in the comments box of this bug.


https://bugzilla.redhat.com/show_bug.cgi?id=592672

--- Comment #4 from Petr Pisar <ppisar@xxxxxxxxxx> 2010-06-15 12:58:40 EDT ---
> Sorry, I didn't understand the difference.

Problem is not with 'config*'. Problem is with shell substitution (the
back-ticks).

Lets have code: rm -rf `command`

If command expands to 'filename', resulting command will be:
  'rm' '-rf' 'filename'
If command expands to 'file name', resulting command will be:
  'rm' '-rf' 'file' 'name'.
And this is not something we wanted. You can have dangerous file names like
'/tmp/ /home' that ticks your script to remove '/tmp' and '/home' directories
instead of 'home' directory under ' ' directory under '/tmp'.


> Should I change each removal to use "find -name 'config*' -exec rm -rf -- '{}' \+" ?

You can use all the logical ORs, but you should pass the file names to 'rm'
arguments using find utility that does not break strings on white spaces. 

Original code:

%{__rm} -rf `find . \( -name 'config*'   -o  \
                       -name 'windows'   -o  \
                       -name 'Misc'      -o  \
                       -name 'Pod'       -o  \
                       -name '.svn'      -o  \
                       -name '*.svn'         \)`

New code:

find . -depth \( -name 'config*'   -o  \
                 -name 'windows'   -o  \
                 -name 'Misc'      -o  \
                 -name 'Pod'       -o  \
                 -name '.svn'      -o  \
                 -name '*.svn'         \) \
   -exec %{__rm} -rf -- '{}' +

I think the plus symbol does not need to be escaped. Notice: I did not try the
code.

Just for completeness:
  * The '-depth' argument forces find to order file names from leaf to root of
directory tree. This is good not to get warning about removal of files from
already removed directories.
  * The '--' argument of 'rm' delimits 'rm' options and file name arguments.
This is good not to confuse 'rm' if a file name starts with a hyphen character.
  * The '{}' string is substituted by 'find' with found file names.
  * The '+' character marks end of '-exec' statement of find. In addition, it
means to pass to one 'rm' command as much file names as possible. It avoids
executing rm for each file name. (If you wanted to run 'rm' for each file name
separately, use ';'. Do not forget to escape it because semicolon is special
shell token.)


> Do you want me to rename the file to simply hct?

Exactly. If there are no other tools that expect 'hct.pl', the extension in
UN*X word will be useless and make users to type more. (E.g. 'yum' is a python
script and does not have '.py' extensions.)

Actually we need to provide extensionless name because upstream (even dead
state) intends so and users used for HCT from other distribution will expect it
in Fedora too. In other words, we should not divert from upstream.

-- 
Configure bugmail: https://bugzilla.redhat.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
--
Fedora Extras Perl SIG
http://www.fedoraproject.org/wiki/Extras/SIGs/Perl
perl-devel mailing list
perl-devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/perl-devel


[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Legacy Announce]     [Fedora PHP Devel]     [Kernel Devel]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Big List of Linux Books]     [Gimp]     [Yosemite Information]
  Powered by Linux