]> rtime.felk.cvut.cz Git - wvtest.git/commitdiff
sh: use a worse version of _wvfind_caller if bash isn't available.
authorAvery Pennarun <apenwarr@gmail.com>
Tue, 16 Feb 2010 22:03:28 +0000 (17:03 -0500)
committerAvery Pennarun <apenwarr@gmail.com>
Tue, 16 Feb 2010 22:05:56 +0000 (17:05 -0500)
bash has tools for finding the file/linenumber of the caller, but it's not
POSIX, so don't rely on it.

sh/t/twvtest.sh
sh/wvtest.sh

index 875dd5373ce621f45e85d96db2153c657e6ab0be..c02871afd0afefcb9deef9509e73af58fbb5172a 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 . ./wvtest.sh
 
 WVSTART "main test"
index 44f7d9e2d021e446665d0394d227bfd8d4d1a79a..b90c8bf8bb76bd7bf18c6244d87486e3f67a7fbe 100644 (file)
@@ -12,12 +12,23 @@ _wvtextclean()
        ( set -f; echo $* )
 }
 
-_wvfind_caller()
-{
-       LVL=$1
-       WVCALLER_FILE=${BASH_SOURCE[2]}
-       WVCALLER_LINE=${BASH_LINENO[1]}
-}
+
+if [ -n "$BASH_VERSION" ]; then
+       _wvfind_caller()
+       {
+               LVL=$1
+               WVCALLER_FILE=${BASH_SOURCE[2]}
+               WVCALLER_LINE=${BASH_LINENO[1]}
+       }
+else
+       _wvfind_caller()
+       {
+               LVL=$1
+               WVCALLER_FILE="unknown"
+               WVCALLER_LINE=0
+       }
+fi
+
 
 _wvcheck()
 {