diff -r 1bb2d1cf49a5 -r 046cc0beef5b builtins.c
      
        
          
        
        
          
            | a | b |  | 
        
        
          
            | 25 | 25 | # include "variable.h" | 
          
            | 26 | 26 | # include "timestamp.h" | 
          
            | 27 | 27 | # include <ctype.h> | 
        
        
          
            |  | 28 | # include <sys/types.h> | 
          
            |  | 29 | # include <sys/wait.h> | 
        
        
          
            | 28 | 30 |  | 
          
            | 29 | 31 | /* | 
          
            | 30 | 32 | * builtins.c - builtin jam rules | 
        
        
          
            | … | … |  | 
        
        
          
            | 1724 | 1726 | #define pclose _pclose | 
          
            | 1725 | 1727 | #endif | 
          
            | 1726 | 1728 |  | 
        
        
          
            |  | 1729 | static char * rtrim(char *s) | 
          
            |  | 1730 | { | 
          
            |  | 1731 | char *p = s; | 
          
            |  | 1732 | while(*p) ++p; | 
          
            |  | 1733 | for(--p; p >= s && isspace(*p); *p-- = 0); | 
          
            |  | 1734 | return s; | 
          
            |  | 1735 | } | 
          
            |  | 1736 |  | 
        
        
          
            | 1727 | 1737 | LIST *builtin_shell( PARSE *parse, FRAME *frame ) | 
          
            | 1728 | 1738 | { | 
          
            | 1729 | 1739 | LIST* command = lol_get( frame->args, 0 ); | 
        
        
          
            | … | … |  | 
        
        
          
            | 1735 | 1745 | int exit_status = -1; | 
          
            | 1736 | 1746 | int exit_status_opt = 0; | 
          
            | 1737 | 1747 | int no_output_opt = 0; | 
        
        
          
            |  | 1748 | int strip_eol_opt = 0; | 
        
        
          
            | 1738 | 1749 |  | 
          
            | 1739 | 1750 | /* Process the variable args options. */ | 
          
            | 1740 | 1751 | { | 
        
        
          
            | … | … |  | 
        
        
          
            | 1750 | 1761 | { | 
          
            | 1751 | 1762 | no_output_opt = 1; | 
          
            | 1752 | 1763 | } | 
        
        
          
            |  | 1764 | else if ( strcmp("strip-eol", arg->string) == 0 ) | 
          
            |  | 1765 | { | 
          
            |  | 1766 | strip_eol_opt = 1; | 
          
            |  | 1767 | } | 
        
        
          
            | 1753 | 1768 | arg = lol_get( frame->args, ++a ); | 
          
            | 1754 | 1769 | } | 
          
            | 1755 | 1770 | } | 
        
        
          
            | … | … |  | 
        
        
          
            | 1767 | 1782 | buffer[ret] = 0; | 
          
            | 1768 | 1783 | if ( ! no_output_opt ) | 
          
            | 1769 | 1784 | { | 
        
        
          
            |  | 1785 | if ( strip_eol_opt ) | 
          
            |  | 1786 | rtrim(buffer); | 
        
        
          
            | 1770 | 1787 | string_append( &s, buffer ); | 
          
            | 1771 | 1788 | } | 
          
            | 1772 | 1789 | } | 
        
        
          
            | … | … |  | 
        
        
          
            | 1780 | 1797 | /* The command exit result next. */ | 
          
            | 1781 | 1798 | if ( exit_status_opt ) | 
          
            | 1782 | 1799 | { | 
        
        
          
            |  | 1800 | if ( WIFEXITED(exit_status) ) | 
          
            |  | 1801 | exit_status = WEXITSTATUS(exit_status); | 
          
            |  | 1802 | else | 
          
            |  | 1803 | exit_status = -1; | 
        
        
          
            | 1783 | 1804 | sprintf (buffer, "%d", exit_status); | 
          
            | 1784 | 1805 | result = list_new( result, newstr( buffer ) ); | 
          
            | 1785 | 1806 | } |