bd899aff4b3713e73534be2c2a93c181c9d6b511
[platform/upstream/coreutils.git] / tests / misc / head-c
1 #!/bin/sh
2 # exercize the fix of 2001-08-18, based on test case from Ian Bruce
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   head --version
7 fi
8
9 pwd=`pwd`
10 tmp=head-c.$$
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 echo abc > in || framework_failure=1
18
19 if test $framework_failure = 1; then
20   echo 'failure in testing framework' 1>&2
21   (exit 1); exit 1
22 fi
23
24 fail=0
25
26 (head -c1; head -c1) < in > out || fail=1
27 case "`cat out`" in
28   ab) ;;
29   *) fail=1 ;;
30 esac
31
32 (exit $fail); exit $fail