when using expressions like ${#1} (string length of parameter) in bash scripts, the syntax highlighting in incorrect for certain usages, for example in lines like var3=${2:0:${#1}} (see examples at "Steps to Reproduce") Generally noteble is the fact, that the following line is completely colored in cyan foo=${#bar} whereas in the line foo=${#1} the dollar character gets black. This gives a hint, that the strings after # are only detected properly, if they do not start with a number Reproducible: Always Steps to Reproduce: 1) save the following text as a file with suffix .sh in kate or kwrite # Example1: function_foo() { var1=$1 var2=${2:0:${#var1}} # --> displayed correctly var3=${2:0:${#1}} # --> not displayed correctly echo "var1: $var1 var2: $var2 var3: $var3" } function_foo "xyz" "abcdef" # output: var1: xyz var2: abc var3: abc # -------------------------- # Example 2: my_variable1=${1:-"${#0}"} # --> displayed correctly tempvar=$0 my_variable2=${1:-${#tempvar}} # --> displayed correctly my_variable3=${1:-${#0}} # --> not displayed correctly echo "my_variable1: $my_variable1" echo "my_variable2: $my_variable2" echo "my_variable3: $my_variable3" Actual Results: the last closing curly bracket in line var3=${2:0:${#1}} is black (instead of green) marked as closing function_foo, and the chars ${# are underlined and brownish ------ in the line my_variable3=${1:-${#0}} the chars ${#0 are written black (instead of green), and the last bracket } is marked to close the expression "${#0}}" instead of the expression "${1:-${#0}}" Expected Results: the line var3=${2:0:${#1}} should look exacly like the line var2=${2:0:${#var1}} with "1" instead of "var1" (all cyan) and showing that the brackets have no matching brackets elsewhere. ----- the line my_variable3=${1:-${#0}} should look exacly like line my_variable2=${1:-${#tempvar}} with "0" instead of "tempvar" (all cyan) and show the matching bracket correctly Version 3.8.4 Using KDE Development Platform 4.8.4 (4.8.4) A workaround could be using additional quoting like my_variable3=${1:-"${#0}"}
Created attachment 77218 [details] screenshot of the .sh file in kate
Git commit 5a5c7f37c061bf8b68346861057848df65268b7a by Joseph Wenninger. Committed on 24/01/2014 at 00:15. Pushed by jowenn into branch 'master'. This should fix "length of input parameter" highlighting for bash FIXED-IN: 5.0 M +2 -1 src/syntax/data/bash.xml http://commits.kde.org/ktexteditor/5a5c7f37c061bf8b68346861057848df65268b7a