$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r65232 - trunk/tools/build/v2/engine/src
From: ghost_at_[hidden]
Date: 2010-09-04 06:10:39
Author: vladimir_prus
Date: 2010-09-04 06:10:34 EDT (Sat, 04 Sep 2010)
New Revision: 65232
URL: http://svn.boost.org/trac/boost/changeset/65232
Log:
Add 'strip-eol' option to SHELL. Also, return actual exit status.
Previously, with the 'exit-code' option SHELL would return raw
value from waitXXX, with exit status shifted 8 bits to the left.
Fixes #4470.
Text files modified: 
   trunk/tools/build/v2/engine/src/builtins.c |    21 +++++++++++++++++++++                   
   1 files changed, 21 insertions(+), 0 deletions(-)
Modified: trunk/tools/build/v2/engine/src/builtins.c
==============================================================================
--- trunk/tools/build/v2/engine/src/builtins.c	(original)
+++ trunk/tools/build/v2/engine/src/builtins.c	2010-09-04 06:10:34 EDT (Sat, 04 Sep 2010)
@@ -26,6 +26,8 @@
 #include "timestamp.h"
 #include "md5.h"
 #include <ctype.h>
+# include <sys/types.h>
+# include <sys/wait.h>
 
 
 /*
@@ -2170,6 +2172,14 @@
 #endif
 
 
+static char * rtrim(char *s)
+{
+    char *p = s;
+    while(*p) ++p;
+    for(--p; p >= s && isspace(*p); *p-- = 0);
+    return s;
+}
+
 LIST * builtin_shell( PARSE * parse, FRAME * frame )
 {
     LIST   * command = lol_get( frame->args, 0 );
@@ -2181,6 +2191,7 @@
     int      exit_status = -1;
     int      exit_status_opt = 0;
     int      no_output_opt = 0;
+    int      strip_eol_opt = 0;
 
     /* Process the variable args options. */
     {
@@ -2196,6 +2207,10 @@
             {
                 no_output_opt = 1;
             }
+            else if ( strcmp("strip-eol", arg->string) == 0 )
+            {
+                strip_eol_opt = 1;
+            }
             arg = lol_get( frame->args, ++a );
         }
     }
@@ -2217,6 +2232,8 @@
         buffer[ret] = 0;
         if ( !no_output_opt )
         {
+            if ( strip_eol_opt )
+                rtrim(buffer);
             string_append( &s, buffer );
         }
     }
@@ -2230,6 +2247,10 @@
     /* The command exit result next. */
     if ( exit_status_opt )
     {
+        if ( WIFEXITED(exit_status) )
+            exit_status = WEXITSTATUS(exit_status);
+        else
+            exit_status = -1;
         sprintf( buffer, "%d", exit_status );
         result = list_new( result, newstr( buffer ) );
     }