Community
    • Login

    Function List with Bash scripts not fully populating

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    12 Posts 6 Posters 996 Views
    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 BedellM
      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
      • MAPJe71M
        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.

        Robert MahnR 1 Reply Last reply Reply Quote 2
        • Robert MahnR
          Robert Mahn @MAPJe71
          last edited by

          @MAPJe71 This problem still exists, at least for having a comment line after the function definition.

          MAPJe71M 1 Reply Last reply Reply Quote 0
          • MAPJe71M
            MAPJe71 @Robert Mahn
            last edited by

            @Robert-Mahn

            Still no problem for me with

            <?xml version="1.0" encoding="UTF-8" ?>
            <!-- ==========================================================================\
            |
            |   To learn how to make your own language parser, please check the following
            |   link:
            |       https://npp-user-manual.org/docs/function-list/
            |
            \=========================================================================== -->
            <NotepadPlus>
            	<functionList>
            		<parser
            			displayName="BASH - Bourne-Again SHell"
            			id         ="bash_function"
            			commentExpr="(?x)                                                   # free-spacing (see `RegEx - Pattern Modifiers`)
            						(?-s:(?:^\x23(?!!)|^\h*\x23|\h+\x23).*$)                # Single Line Comment 1..3
            					|	(?s:\x22(?:[^\x22\x5C]|\x5C.)*\x22)                     # String Literal - Double Quoted
            					|	(?s:\x27[^\x27]*\x27)                                   # String Literal - Single Quoted
            					|	(?:                                                     # Here Document (Type 1) and Here String
            							(?ms)                                               # - ^, $ and dot match at line-breaks
            							\x3C{2,3}\h*                                        # - start-of indicator
            							(?'HD1ID'                                           # - identifier, store for back-reference
            								[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*                #   ...valid character combination for identifier
            								\b                                              #   ...ensure trailing word boundary
            							)
            							.*?                                                 # - whatever, until...
            							^\k'HD1ID'                                          #   ...exactly the same identifier in the first column
            						)
            					|	(?:                                                     # Here Document (Type 2)
            							(?ms)                                               # - ^, $ and dot match at line-breaks
            							\x3C{2}-\h*                                         # - start-of indicator
            							(?'HD2ID'                                           # - identifier, store for back-reference
            								[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*                #   ...valid character combination for identifier
            								\b                                              #   ...ensure trailing word boundary
            							)
            							.*?                                                 # - whatever, until...
            							^\h*\k'HD2ID'                                       #   ...exactly the same identifier
            						)
            				"
            		>
            			<function
            				mainExpr="(?x)                                                  # free-spacing (see `RegEx - Pattern Modifiers`)
            						(?m)                                                    # ^ and $ match at line-breaks
            						^\h*                                                    # optional leading white-space at start-of-line
            						(?:
            							(?-i:function)\s+
            							(?'VALID_ID'                                        # valid identifier, use as subroutine
            								\b(?!(?-i:                                      # keywords (case-sensitive), not to be used as identifier
            									do(?:ne)?
            								|	el(?:if|se)|esac
            								|	f(?:i|or|unction)
            								|	i[fn]
            								|	select
            								|	t(?:hen|ime)
            								|	until
            								|	while
            								)\b)
            								[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*                # valid character combination for identifiers
            							)
            							(?:\s*\([^()]*?\))?                                 # parentheses and parameters optional
            						|
            							(?&amp;VALID_ID)
            							\s*\([^()]*?\)                                      # parentheses required, parameters optional
            						)
            						[^{;]*?\{                                               # no semi-colon until start of body
            					"
            			>
            				<functionName>
            					<nameExpr expr="\b(?!function\b)\w+(?:\s*\([^()]*\))?" />
            					<!-- comment out the following node to display the function with its parameters -->
            					<nameExpr expr="\w+(?=\b)" />
            				</functionName>
            			</function>
            		</parser>
            	</functionList>
            </NotepadPlus>
            
            Michael VincentM 1 Reply Last reply Reply Quote 0
            • Michael VincentM
              Michael Vincent @MAPJe71
              last edited by

              @MAPJe71 said in Function List with Bash scripts not fully populating:

              Still no problem for me with

              Using your ‘bash.xml’ in my ‘functionList’ directory, I still see the issue:

              30c01018-f832-4ae8-9c7c-cc4b87e1b3af-image.png

              97fdac5c-9adb-4a61-a74c-6be16290e3a6-image.png

              The code used:

              port2dec()
              {
                  local a b ip=$@
                  IFS=. read -r a b <<< "$ip"
                  printf '%d\n' "$((a * 256 + b))"
              }
              
              stop_l2tp()
              {
              
                  # IPSec down
                  for seccon in `awk '/conn / {print $2}' /etc/ipsec.conf`
                  do
                      ipsec down $seccon
                  done
                  # clean
                  rm -f /etc/ipsec.conf
                  rm -f /etc/ipsec.secrets
                  # recreate
                  cat <<EOF >> /etc/ipsec.conf
              config setup
              
              EOF
                  touch /etc/ipsec.secrets
              
                  # L2TP interfaces and tunnels down
                  ip link set dev $L2TP_BR down
                  brctl delbr $L2TP_BR
                  for intf in `ifconfig -a | awk '/l2tp/ {print $1}'`
                  do
                      ip link set dev ${intf::-1} down
                      ip l2tp del tunnel tunnel_id ${intf:4:-1}
                  done
              
                  ebtables -F $EBTABLES_TABLE
              }
              
              start_l2tp()
              {
                  sysctl net.ipv4.ip_forward=1
              
                  # Block DHCP from bridge
                  for i in "${EBTABLES_RULES[@]}"
                  do
                      ebtables -I $i
                  done
              }
              

              Cheers.

              MAPJe71M 1 Reply Last reply Reply Quote 2
              • MAPJe71M
                MAPJe71 @Michael Vincent
                last edited by

                @Michael-Vincent

                In addition I have the following line in the overrideMap.xml:

                <association id="bash.xml"  langID="26" />
                
                1 Reply Last reply Reply Quote 0
                • MAPJe71M
                  MAPJe71
                  last edited by

                  Notepad++ v8.3.3   (32-bit)
                  Build time : Mar 13 2022 - 17:11:10
                  Path : C:\Program Files (x86)\Notepad++\notepad++.exe
                  Command Line : 
                  Admin mode : OFF
                  Local Conf mode : OFF
                  Cloud Config : OFF
                  OS Name : Windows 10 Home (64-bit) 
                  OS Version : 1607
                  OS Build : 14393.2189
                  Current ANSI codepage : 1252
                  Plugins : ChangedLines.dll CodeAlignmentNpp.dll CustomizeToolbar.dll DoxyIt.dll InsertLoremIpsum.dll JSLintNpp.dll JSMinNPP.dll LuaScript.dll MarkdownViewerPlusPlus.dll mimeTools.dll NppConverter.dll NppEditorConfig.dll NppEventExec.dll NppExec.dll NppExport.dll NppMarkdownPanel.dll NppSnippets.dll NppUISpy.dll PreviewHTML.dll PythonScript.dll SurroundSelection.dll TagsView.dll XMLTools.dll 
                  
                  1 Reply Last reply Reply Quote 0
                  • F
                    futska
                    last edited by

                    The problem is this line in the Bash parser in functionList.xml.

                    (?-s:(?:^\x23[^!]|^\h*\x23|\h+\x23).*$)         # Single Line Comment
                    

                    The regex for a Bash Single Line Comment is matching a # and the line above/below it. I am not sure how to fix it.

                    PeterJonesP 1 Reply Last reply Reply Quote 0
                    • PeterJonesP
                      PeterJones @futska
                      last edited by

                      @futska said in Function List with Bash scripts not fully populating:

                      The problem is this line in the Bash parser in functionList.xml.

                      The functionList.xml hasn’t been used since before v7.9 was released in late 2020: each language now has its own config file in a subdirectory instead. Have you tried in a modern version of Notepad++?

                      F 1 Reply Last reply Reply Quote 0
                      • F
                        futska @PeterJones
                        last edited by

                        Ah, ok thanks. I am using a newer version, but I use the portable version and keep installing over previous installs. I wondered why the regex changes I was making were having no impact,

                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors