File: guess-2.tst

package info (click to toggle)
a2ps 1:4.14-1.1+deb6u1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 12,324 kB
  • ctags: 4,908
  • sloc: ansic: 26,659; sh: 13,155; lex: 2,286; perl: 1,156; yacc: 757; makefile: 605; lisp: 398; ada: 263; objc: 189; f90: 109; ml: 85; sql: 74; pascal: 57; modula3: 33; haskell: 32; sed: 30; java: 29; python: 24
file content (58 lines) | stat: -rwxr-xr-x 1,924 bytes parent folder | download | duplicates (12)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /bin/sh
# -*- ksh -*-

# guess2.tst
# Check that a2ps is able to use file(1) on stdin.
# Do _not_ report an error if a2ps failed to recognize PostScript files
# when file itself fails.  But display a big warning though.

: ${SRCDIR=.}
. $SRCDIR/defs || exit 1

# Get the type verdict from a2ps
get_type='sed -e s/[^(]*(//g;s/)[^)]*//g'

# Check that guesses are OK for stdin filename
# No argument, no content
res=`echo | $CHK --guess --stdin=foo.ps | $get_type` || exit 1
test "$res" = ps || exit 1

# Argument is -, no content
res=`echo | $CHK --guess --stdin=foo.ps - | $get_type` || exit 1
test "$res" = ps || exit 1

# No arg, no specified title, no content
res=`echo | $CHK --guess | $get_type` || exit 1
test "$res" = plain || exit 1

# No arg, no specified title, a ps content
# This test relies upon a good file(1) (i.e. a good etc/magic).
res=`cat $TST_DIR/ehandler | $CHK --guess | $get_type` || exit 1
if test "$res" = ps; then :; else
  # We have failed to recognize a ps file.  Is it because of file(1)?
  set -- `$CHK --guess -vtools $TST_DIR/ehandler 2>&1 | grep '^file(1)'`
  case "$3$4" in
    PostScript|postscript)
      # a2ps is truly responsible
      exit 1
      ;;

    *)
      # a2ps is not responsible
      exec 1>&2
      echo "*****************************************************************"
      echo "* Your file(1) is sadly broken.  It does not recognize PostScript"
      echo "* files.  You may have unexpected results such as pretty printing"
      echo "* of the _source_ of your PostScript documents."
      echo "* To avoid this problem ask your system administrator to update"
      echo "* etc/magic, so that running"
      echo "*    file $TST_DIR/ehandler"
      echo "* correctly answers \`PostScript document'"
      echo "*****************************************************************"
      # Consider the test is succesful
      exit 0
      ;;
    esac
fi

exit 0