[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
possible bash bug...
From: |
George . R . Goffe |
Subject: |
possible bash bug... |
Date: |
Mon, 23 Jul 2001 12:32:52 -0700 |
Hi there,
I may be barking up the wrong tree here but I think I've found a bash bug.
Let me explain.
I have a script that has functions in it. From the main line I issue a
function call to func1 and pass a parameter. Func1 issues a function call
to func2 which returns a number, or rather should return a number. What I
get is the parameter string passed to func1. The origional function call
returns nothing.
Is this a case of me not knowing enough about scripting or is this a bug? I
have enclosed the script below. In an attempt to illustrate the structure
of the script I have placed echo statements at the beginning of each
function which PRODUCES even stranger (to me anyway) results.
Regards and thanks for your time,
George...
./tst
#!/usr/lsd/SunOS.5.8/bin/bash -xv
func1()
{
echo ''
echo 'func1 entered..............................'
func1_v=$1 # save the incomming parameter...
func1_r=`func2 $func1_v` # set the func1 return variable to
whatever func2 returns...
return $func1_r
}
func2()
{
echo ''
echo 'func2 entered..............................'
func2_v=$1 # save the incomming parameter...
return 2 # return a 2...
}
# pass func1 a 0 and set wtf to whatever func1 returns...
wtf=`func1 0`
func1 0
++ func1 0
++ echo ''
++ echo 'func1 entered..............................'
++ func1_v=0
func2 $func1_v
+++ func2 0
+++ echo ''
+++ echo 'func2 entered..............................'
+++ func2_v=0
+++ return 2
++ func1_r=
func2 entered..............................
++ return func2 entered..............................
./tst: return: bad non-numeric arg `func2'
- possible bash bug...,
George . R . Goffe <=