Navigation

    Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Function List with Bash scripts not fully populating

    Help wanted · · · – – – · · ·
    3
    4
    90
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Michael Bedell
      Michael Bedell last edited by

      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 Vincent 1 Reply Last reply Reply Quote 0
      • Michael Vincent
        Michael Vincent @Michael Bedell last edited by

        @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.

        1 Reply Last reply Reply Quote 4
        • Michael Bedell
          Michael Bedell last edited by

          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!

          1 Reply Last reply Reply Quote 2
          • MAPJe71
            MAPJe71 last edited by

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

            1 Reply Last reply Reply Quote 2
            • First post
              Last post
            Copyright © 2014 NodeBB Forums | Contributors