blob: 919d82bcd304ef9e505e1b795c12db2d21533685 [file] [log] [blame]
Jari Aaltobb706242000-03-17 21:46:59 +00001#
Chet Rameyac50fba2014-02-26 09:36:43 -05002# Chet Ramey <chet.ramey@case.edu>
3#
4# Copyright 1999 Chester Ramey
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2, or (at your option)
9# any later version.
10#
11# TThis program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software Foundation,
18# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19#
Jari Aaltobb706242000-03-17 21:46:59 +000020# replacements for test/[ that do arithmetic expansion on the operands to
21# the arithmetic operators, like ksh.
22#
23function test()
24{
25 local -i n1 n3
26 case "$#" in
27 3) case "$2" in
28 -lt|-gt|-eq|-ne|-le|-ge) n1=$(( $1 ))
29 n3=$(( $3 ))
30 builtin test "$n1" $2 "$n3"
31 return $?;;
32 *) builtin test "$@" ;;
33 esac;;
34 *) builtin test "$@" ;;
35 esac
36}
37
38function [()
39{
40 local -i n1 n3
41 case "$#" in
42 4) case "$2" in
43 -lt|-gt|-eq|-ne|-le|-ge) n1=$(( $1 ))
44 n3=$(( $3 ))
45 builtin [ "$n1" $2 "$n3" ]
46 return $?;;
47 *) builtin [ "$@" ;;
48 esac;;
49 *) builtin [ "$@" ;;
50 esac
51}
52
53q=7
54
55[ q -lt 10 ]
56echo $?
57[ $q -lt 10 ]
58echo $?