summaryrefslogtreecommitdiff
path: root/tests/ls-2/quoting
blob: 51545fbe6ac24ab99fa599365bed12661b8978b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl -w
require 5.003;
use strict;

(my $program_name = $0) =~ s|.*/||;

# Make sure the tools use the expected locale.
$ENV{LANGUAGE} = 'C';
$ENV{LC_ALL} = 'C';
$ENV{LANG} = 'C';

my $q_bell = {IN => {"q\a" => ''}};
my @Tests =
    (
     # test-name options input expected-output
     #
     ['q-',        $q_bell, {OUT => "q\a\n"}],
     ['q-N', '-N', $q_bell, {OUT => "q\a\n"}],
     ['q-q', '-q', $q_bell, {OUT => "q?\n"}],
     ['q-Q', '-Q', $q_bell, {OUT => "\"q\\a\"\n"}],

     ['q-lit-q', '--quoting=literal -q',     $q_bell, {OUT => "q?\n"}],
     ['q-qs-lit', '--quoting=literal',       $q_bell, {OUT => "q\a\n"}],
     ['q-qs-sh', '--quoting=shell',          $q_bell, {OUT => "q\a\n"}],
     ['q-qs-sh-a', '--quoting=shell-always', $q_bell, {OUT => "'q\a'\n"}],
     ['q-qs-c', '--quoting=c',               $q_bell, {OUT => "\"q\\a\"\n"}],
     ['q-qs-esc', '--quoting=escape',        $q_bell, {OUT => "q\\a\n"}],
    );

my $save_temps = 0;
my $verbose = $ENV{VERBOSE};

my $prog = $ENV{LS} || 'ls';
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
exit $fail;