46fa6d901bc719306eba8838cc52513d5fc905b4
[platform/upstream/coreutils.git] / tests / ls / no-arg
1 #!/bin/sh
2 # make sure ls and `ls -R' do the right thing when invoked with no arguments.
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   ls --version
7 fi
8
9 pwd=`pwd`
10 tmp=no-args.$$
11 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
12 trap '(exit $?); exit' 1 2 13 15
13
14 framework_failure=0
15 mkdir $tmp || framework_failure=1
16 cd $tmp || framework_failure=1
17 mkdir -p dir/subdir || framework_failure=1
18 touch dir/subdir/file2 || framework_failure=1
19 ln -s f symlink || framework_failure=1
20
21 cat > exp <<\EOF || framework_failure=1
22 dir
23 exp
24 out
25 symlink
26 EOF
27
28 if test $framework_failure = 1; then
29   echo 'failure in testing framework'
30   (exit 1); exit 1
31 fi
32
33 fail=0
34
35 ls -1 > out || fail=1
36
37 cmp out exp || fail=1
38 test $fail = 1 && diff out exp 2> /dev/null
39
40 cat > exp <<\EOF
41 .:
42 dir
43 exp
44 out
45 symlink
46
47 ./dir:
48 subdir
49
50 ./dir/subdir:
51 file2
52 EOF
53
54 ls -R1 > out || fail=1
55
56 cmp out exp || fail=1
57 test $fail = 1 && diff out exp 2> /dev/null
58
59 (exit $fail); exit $fail