Index: portbuild.tcl
===================================================================
--- portbuild.tcl	(revision 65035)
+++ portbuild.tcl	(working copy)
@@ -104,7 +104,7 @@
 }
 
 proc portbuild::build_getnicevalue {args} {
-    if {![exists build.nice] || [string match "* *" [option build.cmd]]} {
+    if {![exists build.nice]} {
         return ""
     }
     set nice [option build.nice]
@@ -165,7 +165,27 @@
     set jobs_suffix [build_getjobsarg]
 
     set realcmd ${build.cmd}
-    set build.cmd "$nice_prefix${build.cmd}$jobs_suffix"
+    set build.cmd [list]
+
+    # If build.cmd can be a series of commands, we need to iterate through the
+    # list and apply nice to commands that are not shell built-in commands.
+    set add_nice_prefix 1
+    foreach word [split [join $realcmd]] {
+        # Only the first word in build.cmd and words that follow the control
+        # operators && and || should be commands.
+        if {$add_nice_prefix && ![catch {findBinary $word} result]} {
+            lappend build.cmd "$nice_prefix$word"
+        } else {
+            lappend build.cmd $word
+        }
+        set add_nice_prefix 0
+
+        if {$word eq "&&" || $word eq "||"} {
+            set add_nice_prefix 1
+        }
+    }
+    set build.cmd "[join ${build.cmd}]$jobs_suffix"
+
     command_exec build
     set build.cmd ${realcmd}
     return 0

