563857ce3e2a53fb6e53a3d015ab4543c5ae37ec
[platform/upstream/coreutils.git] / tests / dircolors / simple
1 #!/bin/sh
2
3 : ${PERL=perl}
4 : ${srcdir=.}
5
6 $PERL -e 1 > /dev/null 2>&1 || {
7   echo 1>&2 "$0: configure didn't find a usable version of Perl," \
8     "so can't run this test"
9   exit 77
10 }
11
12 exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF
13 require 5.003;
14 use strict;
15
16 (my $program_name = $0) =~ s|.*/||;
17
18 # Turn off localisation of executable's ouput.
19 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
20
21 my @Tests =
22     (
23      ['a', {IN => {k => "exec\n"}},
24       {ERR => "dircolors: k:1: invalid line;  missing second token\n"},
25       {EXIT => 1}],
26      ['quote', '-b', {IN => "exec 'echo Hello;:'\n"},
27       {OUT => "LS_COLORS='ex='\\''echo Hello;\\:'\\'':';\n"
28       . "export LS_COLORS\n"}],
29      ['other-wr', '-b', {IN => "owt 40;33\n"},
30       {OUT => "LS_COLORS='tw=40;33:';\nexport LS_COLORS\n"}],
31
32      # CAREFUL: always specify the -b option, unless explicitly testing
33      # for csh syntax output.
34     );
35
36 my $save_temps = $ENV{DEBUG};
37 my $verbose = $ENV{VERBOSE};
38
39 my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
40 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
41 exit $fail;
42 EOF