Re: PHP 5.3: IUS vs CentOS repos

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



On Sat, Aug 20, 2011 at 01:49:12PM +0100, Always Learning wrote:
> 
> On Sat, 2011-08-20 at 07:43 -0400, Robert Heller wrote:
> 
> > (I did some magic with rpm -qa php\* & sed to get the proper list of
> > stuff to remove and then install.)
> 
> One does not require the '\'

Yes you do.  Especially if there are any files in the directory that would
match php*.  Basically the shell will attempt to do glob expansion on php*
(so if you have php.ini and php.conf in the directory then it'll expand
to those).  Only if no files match will it leave the php* as php*.

So general good practice is to _always_ quote * (and ?) characters on
command lines.  You can either \ the character or put the whole thing
inside '

eg
  rpm -qa 'php*'
or
  rpm -qa php\*

But
  rpm -qa php*
is considered bad and _may_ break and should not be used.  It's just bad
practice.

Watch:
  $ ls
  $

So an empty directory.  We'd expect the command to work...
  $ rpm -qa php*
  php-mbstring-5.1.6-27.el5_5.3
  php-common-5.1.6-27.el5_5.3
  php-cli-5.1.6-27.el5_5.3
  php-5.1.6-27.el5_5.3

Yup!  So far so good.  Now let's create some random files...
  $ touch php.foobar php.ini php.baz
  $ rpm -qa php*                    
  $

Huh, no results.  Let's debug...
  $ set -x
  $ rpm -qa php*                    
  + rpm -qa php.baz php.foobar php.ini
  $ 

You can see the shell has done what I described; php* has been expanded
(since it's a file glob) to the files in the directory that matched

Quoting solves the problem:
  $ rpm -qa php\*
  + rpm -qa 'php*'
  php-mbstring-5.1.6-27.el5_5.3
  php-common-5.1.6-27.el5_5.3
  php-cli-5.1.6-27.el5_5.3
  php-5.1.6-27.el5_5.3

(Debug mode was still on, so you can see how the shell handled it).

Conclusion: when using * (or ?) on the command line, ALWAYS quote it to
avoid unexpected side effects.

-- 

rgds
Stephen
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux