[cfe-commits] r53635 - /cfe/trunk/utils/scan-build

Ted Kremenek kremenek at apple.com
Tue Jul 15 13:22:13 PDT 2008


On Jul 15, 2008, at 1:00 PM, Sam Bishop wrote:

> Hi, Ted!
>
> On Tue, Jul 15, 2008 at 12:28 PM, Ted Kremenek <kremenek at apple.com>  
> wrote:
>> Quote file names to better handle paths with spaces.
>
> I'll tell you how I handle this issue.  Spaces are by far the most
> common problem, but there's also a chance that a path could shell
> meta-characters.
>
> In Perl, the difference between backticks and the system() function is
> that the former allows you to capture a program's output and the
> latter lets you avoid invoking the system shell--if you give it a
> list.  Because you're not capturing any output, you could easily do
> the latter.
>
> By default, the system() function passes its argument to a sub-shell
> if it detects any shell meta-characters.  (This
> avoiding-a-sub-shell-if-possible behavior is simply an optimization.)
> However, if you pass system() a list, it will always execute those
> arguments directly.  So, for instance, `mv $fname.tmp $fname` could be
> replaced with system("mv", "$fname.tmp", $fname).  Spaces,
> single-quotes, double-quotes, dollar signs, etc are no longer a
> problem.
>
> Sam Bishop

Excellent suggestion.  Implemented:

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080714/006506.html

Thanks Sam!



More information about the cfe-commits mailing list