unique_incrementing_runvar next_unique_name
stashfilecontents
- target_cmd_root_status
+ target_cmd_root_status target_cmd_output_root_status
target_cmd_root target_cmd target_cmd_build
target_cmd_output_root target_cmd_output
target_cmd_inputfh_root sshuho
sub tcmdout {
my $stdout= IO::File::new_tmpfile();
- tcmd(undef,$stdout,0,@_);
+ my $badstatusok = $_[1];
+ my $rc = tcmd(undef,$stdout,@_);
$stdout->seek(0,0) or die "$stdout $!";
my $r;
{ local ($/) = undef;
$r= <$stdout>; }
die "$stdout $!" if !defined $r or $stdout->error or !close $stdout;
chomp($r);
+ return ($rc, $r) if $badstatusok;
return $r;
}
# Like target_cmd[_root], but collect the stdout and return it as a string.
-sub target_cmd_output ($$;$) { tcmdout('osstest',@_); }
-sub target_cmd_output_root ($$;$) { tcmdout('root',@_); }
+# Like target_cmd[_root], but collects the stdout and returns it as a string.
+sub target_cmd_output ($$;$) { tcmdout(0, 'osstest',@_); }
+sub target_cmd_output_root ($$;$) { tcmdout(0, 'root',@_); }
+
+# Like target_cmd_root_status but returns a tuple ($?, $stdout_data).
+sub target_cmd_output_root_status ($$;$$) { tcmdout(1, 'root',@_); }
sub target_cmd_inputfh_root ($$$;$$) {
my ($tho,$stdinfh,$tcmd,@rest) = @_;