#776731 posh: Forgetting functions

Package:
posh
Source:
posh
Description:
Policy-compliant Ordinary SHell
Submitter:
Hincor
Date:
2015-01-31 21:24:06 UTC
Severity:
normal
#776731#5
Date:
2015-01-31 21:11:08 UTC
From:
To:
When redefining fun2 within fun2 compound-command it magically forgets fun1.


This is a stripped down example of demonstrating the problem. Problem
was encountered in practice when using multiple(3 or more) "collapsing
function" in script ran by posh.
http://wiki.bash-hackers.org/howto/collapsing_functions

In func.sh
    #!/bin/sh

    fun1 ()
    {
      fun1 ()
      {
        echo "fun1"
      }
    }
    fun2 ()
    {
      fun2 ()
      {
        echo "fun2"
      }
    }
    # Initialization
    fun2
    fun1

    # Echoing
    fun2
    fun1
    fun1
    fun2

# Version: 0.5.7.4
In dash:
    $ dash func.sh
    fun2
    fun1
    fun1
    fun2

In posh:
    $ posh func.sh
    func.sh:19: fun1: not found
    fun2
    func.sh:23: fun1: not found
    func.sh:24: fun1: not found
    fun2