new tool
[hband-tools.git] / tabdata / td-keepheader
blob66f8e862dba4191403fe62c5c2cebee63e14b201
1 #!/usr/bin/env perl
3 =pod
5 =head1 NAME
7 td-keepheader - Plug a non header-aware program in the tabular-data processing pipeline
9 =head1 USAGE
11 td-keepheader [--] <COMMAND> [<ARGS>]
13 =head1 EXAMPLE
15 ls -l | td-trans-ls | td-select NAME +REST | td-keepheader sort | tabularize
17 =cut
19 no if ($] >= 5.018), 'warnings' => 'experimental::smartmatch';
20 do '/usr/lib/tool/perl5/tabdata/common.pl' or die "$@";
22 die "$0: no COMMAND given\n" unless @ARGV;
24 $header = sys_read_line();
26 $|++;
27 print $header . $RS;
29 exec {$ARGV[0]} @ARGV;
30 ($errno, $errstr) = (int $!, $!);
31 warn "$ARGV[0]: $errstr\n";
32 exit 125+$errno;