This is the mail archive of the cygwin-apps@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gbs cleanup patch


On Fri, 15 Oct 2004, Charles Wilson wrote:

> Schulman.Andrew wrote:
>
> > As we discussed a day or two ago, here is a patch that cleans up the
> > following aspects of the generic build script (today's CVS version):
>
> > - Replaces all instances of 'if [ ! -d xxx ] ; then mkdir -p xxx ; fi'
> > with just 'mkdir -p xxx'.  The second form is equivalent but simpler.
>
> As long as everyone knows that "mkdir -p xxx" suppresses errors when xxx
> already exists, in addition to creating all intervening dirs in the dirpath
> xxx.  ("mkdir xxx" will exit-with-error if xxx exists)
>
> Is this behavior true on all platforms? (I know gbs doesn't directly support
> cross-compiling, but it actually doesn't require too much modification to do
> so, at present).

Well, it's true for the 'mkdir' from the GNU fileutils/coreutils -- it sez
so right there on the man page:

$ man -p 'col -bx' mkdir | grep -C1 -w -- -p

   -p, --parents
     no error if existing, make parent directories as needed
     ^^^^^^^^^^^^^^^^^^^^

FWIW, the AIX 5.1 manpage says:

   The mkdir command ignores any Directory parameter that names an
   existing directory. No error is issued.

(yeah, it's verbose, all right)...  The AT&T mkdir also seems to concur:

   -p, --parents
     [snip]
     Do not consider an argument directory that already exists to be an error.

In fact, -p seems to be a POSIX option: <http://icewalkers.com/Linux/ManPages/mkdir-1.html>

   -p,--parents
     [snip]
     Ignore arguments corresponding to existing directories.  (Thus, if a
     directory /a exists, then `mkdir /a' is an error, but `mkdir -p /a'
     is not.)

<http://opengroup.org/onlinepubs/009695399/utilities/mkdir.html>:

   -p
     [snip]
     Each dir operand that names an existing directory shall be ignored
     without error.

Don't know if the non-POSIX platforms are as lenient, though.  Again, a
comment in the code, perhaps?

> > - Adds -r to every invocation of xargs.  In every case this is desirable
> > and will prevent errors in null cases.
>
> Do you mean "--no-run-if-empty" ?  I can't find any documentation of a "-r"
> flag to xargs...

$ man -p 'col -bx' xargs | grep -C1 -w -- -r

   --no-run-if-empty, -r
     If the standard input does not contain any nonblanks, do not run

> P.S.  Thanks for doing this.  Your effort is appreciated.

Ditto.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]