#2 allow usage under Bourne shells (/bin/sh)

closed-fixed
nobody
None
5
2004-12-24
2004-11-15
Bobby Nations
No

Steven,

This patch now makes the shUnit and shUnitPlus work
under all flavors of the Bourne shell family from sh to
ksh and bash. The changes were not that bad with only
one tricky addition. They basically come down to the
following:

1. replace Korn shell function definitions with
Bourne shell
definitions. So, I used

somefunc() {

rather than

function somefunc {

2. removed the use of typeset entirely
3. replaced 'print' and 'echo -n' with 'printf'
4. replaced 'whence' with 'type'
5. replaced '[[ ... ]]' with '[ ... ]'
6. replaced integer arithmetic with list processing.
This
requires some explanation. As you already know, the
Korn shell (and Bash) both support limited forms
of integer
arithmetic, which are sufficient for counting via
'(( ))' type
operations. Since the Bourne shells don't have
that, I had
to substitute a form of list processing whereby I
added a
token to a string each time through and counted
them up
at the end. Thus the following pseudocode

while somecondition
do
(( i=i+1 ))
... some operation ...
done
printf "looped through %n times\n" $i

becomes instead

while somecondition
do
i="$i token"
... some operation ...
done
printf "looped through %n times\n" \ `echo $i | wc -w`

I know, it's not very elegant, but it does work

I've tested this patch under sh, pdksh, and bash on
linux so far. I'll also test on solaris and hpux later
this week and let you know how that works out.

Thanks,

Bobby

P.S. I've added exernal dependencies upon the 'wc' and
'ls' commands to compensate for capabilities found in
ksh but not found in sh.

Discussion

  • Bobby Nations
    Bobby Nations
    2004-11-21

    Logged In: YES
    user_id=425916

    This apparently didn't get uploaded the first time around.

    Bobby

     
  • Bobby Nations
    Bobby Nations
    2004-11-21

    patch to allow shUnit to work under both bash and ksh

     
  • Bobby Nations
    Bobby Nations
    2004-12-24

    • status: open --> open-fixed
     
  • Bobby Nations
    Bobby Nations
    2004-12-24

    Logged In: YES
    user_id=425916

    committed change to CVS

     
  • Bobby Nations
    Bobby Nations
    2004-12-24

    • status: open-fixed --> closed-fixed