| 40 | */ |
| 41 | |
| 42 | void argv_from_shell( char const * * argv, LIST * shell, char const * command, |
| 43 | int const slot ) |
| 44 | { |
| 45 | static char jobno[ 4 ]; |
| 46 | |
| 47 | int i; |
| 48 | int gotpercent = 0; |
| 49 | LISTITER iter = list_begin( shell ); |
| 50 | LISTITER end = list_end( shell ); |
| 51 | |
| 52 | assert( 0 <= slot ); |
| 53 | assert( slot < 999 ); |
| 54 | sprintf( jobno, "%d", slot + 1 ); |
| 55 | |
| 56 | for ( i = 0; iter != end && i < MAXARGC; ++i, iter = list_next( iter ) ) |
| 57 | { |
| 58 | switch ( object_str( list_item( iter ) )[ 0 ] ) |
| 59 | { |
| 60 | case '%': argv[ i ] = command; ++gotpercent; break; |
| 61 | case '!': argv[ i ] = jobno; break; |
| 62 | default : argv[ i ] = object_str( list_item( iter ) ); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | if ( !gotpercent ) |
| 67 | argv[ i++ ] = command; |
| 68 | |
| 69 | argv[ i ] = NULL; |
| 70 | } |
| 71 | |
| 72 | |
| 73 | /* Returns whether the given command string contains lines longer than the given |
no test coverage detected