[m-rev.] for review: use xargs in mmake

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 15 19:00:58 AEDT 2002


On 15-Feb-2002, Peter Ross <peter.ross at miscrit.be> wrote:
> fjh wrote:
> > On 14-Feb-2002, Peter Ross <peter.ross at miscrit.be> wrote:
> > > I have only one question: are there any other issues to using xargs?
> >
> > Yes -- the main issue is that it doesn't properly handle file names
> > containing spaces, newlines, single quotes, double quotes, or backslashes.
>
> Do you have any other suggestions on how to solve this problem?  I can only
> think of xargs at the moment.

Well, you can probably use xargs.  You just need to ensure that any file
names which could contain spaces, newlines, single quotes, double quotes,
or backslashes get properly escaped.

Mmake already doesn't handle names containing spaces properly.
You probably don't need to worry too much about quotes or newlines.
Backslashes are the issue that is most likely to cause problems in practice,
because of their use in Windows path names.
In this particular case, I think it's only the $dvs and the $ds variables
which are likely to overflow the command line limit.
And because of the way they are constructed, the only path name separator
they can contain is "/".

So you could try something like the following.

Index: mmake.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmake.in,v
retrieving revision 1.36
diff -u -d -u -r1.36 mmake.in
--- mmake.in	27 Jul 2001 17:06:17 -0000	1.36
+++ mmake.in	15 Feb 2002 07:54:48 -0000
@@ -295,7 +295,12 @@
 export MMAKE_USE_SUBDIRS
 export MERCURY_INT_DIR
 export MERCURY_DEFAULT_GRADE
-cat ${MMAKE_VARS} $dvs $ds $include_makefile $mmake $deps ${MMAKE_RULES} > $tmp
+# XXX put a comment here
+{
+cat "${MMAKE_VARS}"
+echo $dvs $ds | xargs cat
+cat $include_makefile $mmake $deps "${MMAKE_RULES}"
+} > $tmp
 case $# in
 	# Note that we can't use `exec' here, because if we did that,
 	# that `trap' code which removes $tmp would never get executed.

Please fix the XXX ;-)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list