File: iftrue.sh

package info (click to toggle)
inn2 2.2.2.2000.01.31-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,424 kB
  • ctags: 5,722
  • sloc: ansic: 61,219; perl: 9,939; sh: 5,644; makefile: 1,695; awk: 1,567; yacc: 1,548; lex: 249; tcl: 3
file content (24 lines) | stat: -rwxr-xr-x 556 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /bin/sh
##  $Revision: 1.1.1.1 $
##  Perform a test(1) and execute a command string if the test is true;
##  otherwise exit 0.  Usage:
##	testit <test> <command>
##  On some systems (those with a /bin/sh from BSD4.2), the following
##  line in a Makefile will always fail:
##	if [ ! -f x ] ; then echo No x -- stop. ; exit 1 ; else exit 0 ; fi
case $# in
2)
    ;;
*)
    echo "Can't perform test:  wrong number of arguments." 1>&2
    exit 1
    ;;
esac
TEST="$1"
COMMAND="$2"

if eval "test ${TEST}" ; then
    eval "${COMMAND}"
    exit $?
fi
exit 0