Function List with Bash scripts not fully populating



  • So I’m working on a bash script that has right now 252 functions, but only 45 populate in the function list. This has only recently started to happen. In earlier releases I did not have this issue. Can anyone offer assistance please?



  • @Michael-Bedell

    I’ve seen this before and I think it had to do with function definition followed by comment and the function list parser.

    If my Bash functions look like:

    #!/bin/bash
    
    hello_world () {
        echo 'hello, world'
    }
    
    goodbye_world () {
        echo 'goodbye, world'
    }
    
    hello_world
    goodbye_world
    

    I see both hello_world and goodbye_world in the function list. However, add a comment directly after:

    #!/bin/bash
    
    hello_world () {
        echo 'hello, world'
    }
    
    goodbye_world () {
        # goodbye from function list
        echo 'goodbye, world'
    }
    
    hello_world
    goodbye_world
    

    and now I only see hello_world in the function list. Put a blank line between goodbye_world () { and the comment:

    goodbye_world () {
    
        # I'M BACK!!!
        echo 'goodbye, world'
    }
    

    And we’re back in the function list. Maybe your missing functions have comments directly after the definition?

    Hope this helps.

    Cheers.



  • So working from what you were saying I had to look further. I could add just a blank function

    function test {
    }
    

    and it would show up no problem, until I tried to do it below the last function that showed up in the function list.

    So I started commenting out sections and then eventually lines till I found the offender.

    I originally had a line that said:

    echo set superusers=\"root\" >> /etc/grub.d/40_custom
    

    which worked fine and entered the text as I expected in the file.

    BUT it messed with the function identifiers apparently and it wasn’t until I switched it to say:

    echo "set superusers=\"root\"" >> /etc/grub.d/40_custom
    

    that is began to work. So TYVM for your input as it helped me figure out what was causing at least the issue in the function list. Shouldn’t have made a difference, but either way I can now easily see all the functions again!



  • No problem here, all mentioned functions are displayed in the Function List.
    Makes me wonder which parser and N++ version you are using.


Log in to reply