File: iftrue.sh

package info (click to toggle)
inn 1.7.2-4.2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 5,012 kB
  • ctags: 3,173
  • sloc: ansic: 35,576; perl: 7,652; sh: 4,013; makefile: 2,085; awk: 1,567; yacc: 685; tcl: 85; csh: 70
file content (24 lines) | stat: -rwxr-xr-x 552 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
#! /bin/sh
##  $Revision: 1.3 $
##  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