I have one script name check.ksh
which will check some functionality and having different functions for that:
!/bin/ksh
print "start"
val1=$1
val2=$2
func=$3
checkfunc() {
if [[ $val1 != $val2 ]]
then
print "argument differs"
exit 0
else
print "argument same"
exit 1
fi
}
anotherfunc() {
print "blah blah"
}
$func 2&1> testlog.log
print "end"
and another wrapper script name wrapper.ksh
which will use as a wrapper script of check.ksh
:
#!/bin/ksh
wfunc() {
check.sh $1 $2 $3
[[ $? -eq 0 ]] && printf "different argument passed" || printf "same argument passed"
}
wfunc $1 $2 $3
when I run ./wrapper.sh test1 test1 checkfunc
its should print the output as "same argument passed"
as the called script check.sh
exited with 1
but always I am getting $? as 0
I have tried to print some value or using return but same issue, can we return only the output from the function to the wrapper.ksh
note : I cannot remove the print and other things in check.sh
I can only edit the content of checkfunc()
in the check.sh