Ticket #4470: shell.2.patch

File shell.2.patch, 1.6 KB (added by codemonkey@…, 12 years ago)

updated patch against bjam version 3.1.18

  • builtins.c

    diff -r 9c35ada030a5 -r e8a11323f1ef builtins.c
    a b  
    2626#include "timestamp.h"
    2727#include "md5.h"
    2828#include <ctype.h>
     29# include <sys/types.h>
     30# include <sys/wait.h>
    2931
    3032
    3133/*
     
    21132115#endif
    21142116
    21152117
     2118static char * rtrim(char *s)
     2119{
     2120    char *p = s;
     2121    while(*p) ++p;
     2122    for(--p; p >= s && isspace(*p); *p-- = 0);
     2123    return s;
     2124}
     2125
    21162126LIST * builtin_shell( PARSE * parse, FRAME * frame )
    21172127{
    21182128    LIST   * command = lol_get( frame->args, 0 );
     
    21242134    int      exit_status = -1;
    21252135    int      exit_status_opt = 0;
    21262136    int      no_output_opt = 0;
     2137    int      strip_eol_opt = 0;
    21272138
    21282139    /* Process the variable args options. */
    21292140    {
     
    21392150            {
    21402151                no_output_opt = 1;
    21412152            }
     2153            else if ( strcmp("strip-eol", arg->string) == 0 )
     2154            {
     2155                strip_eol_opt = 1;
     2156            }
    21422157            arg = lol_get( frame->args, ++a );
    21432158        }
    21442159    }
     
    21602175        buffer[ret] = 0;
    21612176        if ( !no_output_opt )
    21622177        {
     2178            if ( strip_eol_opt )
     2179                rtrim(buffer);
    21632180            string_append( &s, buffer );
    21642181        }
    21652182    }
     
    21732190    /* The command exit result next. */
    21742191    if ( exit_status_opt )
    21752192    {
     2193        if ( WIFEXITED(exit_status) )
     2194            exit_status = WEXITSTATUS(exit_status);
     2195        else
     2196            exit_status = -1;
    21762197        sprintf( buffer, "%d", exit_status );
    21772198        result = list_new( result, newstr( buffer ) );
    21782199    }