The framework and some applications for escaping shell-commands. So,
it will be possible to called 'rebuild' with '--define "foo bar"'.

2003-12-03  Enrico Scholz  <enrico.scholz@informatik.tu-chemnitz.de>
	* rediffed

2003-11-18  Enrico Scholz  <enrico.scholz@informatik.tu-chemnitz.de>
        * updated (-l switch on 'su')

2003-11-13  Enrico Scholz  <enrico.scholz@informatik.tu-chemnitz.de>
	* created initially
--- mach/scripts/mach.in~escape	2003-12-03 05:32:14.000000000 +0100
+++ mach/scripts/mach.in	2003-12-05 00:54:32.000000000 +0100
@@ -94,6 +94,8 @@
 sourceslist = {}
 aliases = {}
 file = '@SYSCONFDIR@/mach/dist'
+escape_pat = re.compile("([^A-Za-z0-9:,=+-/_@^])")
+escape_rep = r'\\\1'
 execfile (file)
 
 # read user configuration
@@ -107,6 +109,11 @@
 # rpm -q format, users may have customized %_query_all_fmt in ~/.rpmmacros...
 qfmt = '"%{name}-%{version}-%{release}\n"'
 
+def escapeShell(opt, level=1):
+    while level>0:
+        opt   = escape_pat.sub(escape_rep, opt)
+        level = level - 1
+    return opt
 
 ### objects
 class Spec:
@@ -809,12 +816,13 @@
             # install buildrequires if there are
             debug ("Building %s with package stuff %s" % (name, pkgs[name].keys ()))
             if 'buildreqs' in pkgs[name].keys ():
-                buildreqs = string.join (pkgs[name]['buildreqs'])
+                buildreqs     = string.join (pkgs[name]['buildreqs'])
+                buildreqs_esc = map(lambda x: escapeShell(x), pkgs[name]['buildreqs'])
                 print "Building %s" % srpmname
                 debug ("BuildRequires: %s" % buildreqs)
                 try:
         	    self.aptget ("update")
-                    self.aptget ('install -my %s' % buildreqs,
+                    self.aptget ('install -my %s' % string.join(buildreqs_esc),
                                  "Installing BuildRequires", self.progress ())
                     # FIXME: build-dep would be nice but only works on a pkg
                     # in the rpm-src tree apparently
@@ -876,7 +884,8 @@
 
             # rebuild from spec inside chroot, note: using a login shell
             # in order to get a vanilla default environment
-            command = "su -c 'rpmbuild -ba %s /usr/src/rpm/SPECS/%s 2>&1' - machbuild" % (string.join (options), specfile)
+            options_esc = map(lambda x: escapeShell(x), options)
+            command = "su -c 'rpmbuild -ba %s /usr/src/rpm/SPECS/%s 2>&1' - machbuild" % (string.join (options_esc), specfile)
             (status, output) = self.do_chroot (command,
                                                "Rebuilding %s" % srpmname,
                                                True)
