#!/usr/bin/env perl
use strict;
use warnings;
use YAML::XS;

local $/ = undef;

my ( %param, $i ) = %{ YAML::XS::Load( <> ) };

map
{
    printf "call[%d]: [$_]\n", ++ $i;

    system $_;

    if( $? == -1 )
    {
        print "failed to execute: $!\n";
        exit 1;
    }
    elsif ( $? & 127 )
    {
        printf "child died with signal %d, %s coredump\n",
            ( $? & 127 ), ( $? & 128 ) ? 'with' : 'without';
        exit 1;
    }

    my $exit = $? >> 8;
    exit $exit if $exit && print "child exited with value $exit\n";

}@{$param{argv}};

exit 0;
