MCPcopy Create free account
hub / github.com/boostorg/build / exec_cmd

Function exec_cmd

src/engine/execnt.cpp:335–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333 */
334
335void exec_cmd
336(
337 string const * cmd_orig,
338 int32_t flags,
339 ExecCmdCallback func,
340 void * closure,
341 LIST * shell
342)
343{
344 int32_t const slot = get_free_cmdtab_slot();
345 int32_t const is_raw_cmd = is_raw_command_request( shell );
346 string cmd_local[ 1 ];
347
348 /* Initialize default shell - anything more than /Q/C is non-portable. */
349 static LIST * default_shell;
350 if ( !default_shell )
351 default_shell = list_new( object_new( "cmd.exe /Q/C" ) );
352
353 /* Specifying no shell means requesting the default shell. */
354 if ( list_empty( shell ) )
355 shell = default_shell;
356
357 if ( DEBUG_EXECCMD )
358 {
359 if ( is_raw_cmd )
360 out_printf( "Executing raw command directly\n" );
361 else
362 {
363 out_printf( "Executing using a command file and the shell: " );
364 list_print( shell );
365 out_printf( "\n" );
366 }
367 }
368
369 /* If we are running a raw command directly - trim its leading whitespaces
370 * as well as any trailing all-whitespace lines but keep any trailing
371 * whitespace in the final/only line containing something other than
372 * whitespace).
373 */
374 if ( is_raw_cmd )
375 {
376 char const * start = cmd_orig->value;
377 char const * p = cmd_orig->value + cmd_orig->size;
378 char const * end = p;
379 while ( isspace( *start ) ) ++start;
380 while ( p > start && isspace( p[ -1 ] ) )
381 if ( *--p == '\n' )
382 end = p;
383 string_new( cmd_local );
384 string_append_range( cmd_local, start, end );
385 assert( int32_t(cmd_local->size) == raw_command_length( cmd_orig->value ) );
386 }
387 /* If we are not running a raw command directly, prepare a command file to
388 * be executed using an external shell and the actual command string using
389 * that command file.
390 */
391 else
392 {

Callers 1

make1cFunction · 0.70

Calls 14

is_raw_command_requestFunction · 0.85
list_newFunction · 0.85
object_newFunction · 0.85
out_printfFunction · 0.85
list_printFunction · 0.85
string_newFunction · 0.85
string_append_rangeFunction · 0.85
raw_command_lengthFunction · 0.85
prepare_command_fileFunction · 0.85
argv_from_shellFunction · 0.85
string_new_from_argvFunction · 0.85
invoke_cmdFunction · 0.85

Tested by

no test coverage detected