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?
-
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_worldI see both
hello_worldandgoodbye_worldin 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_worldand now I only see
hello_worldin the function list. Put a blank line betweengoodbye_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_customwhich 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_customthat 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. -
@MAPJe71 This problem still exists, at least for having a comment line after the function definition.
-
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 | (?&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> -
@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:


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.
-
In addition I have the following line in the
overrideMap.xml:<association id="bash.xml" langID="26" /> -
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 -
The problem is this line in the Bash parser in functionList.xml.
(?-s:(?:^\x23[^!]|^\h*\x23|\h+\x23).*$) # Single Line CommentThe regex for a Bash Single Line Comment is matching a # and the line above/below it. I am not sure how to fix it.
-
@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.xmlhasn’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++? -
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,