bash-language-server icon indicating copy to clipboard operation
bash-language-server copied to clipboard

Failed to parse expression: "$((16#ffff))" decimal conversion

Open fakuivan opened this issue 6 years ago • 2 comments

#!/usr/bin/env bash
function to_decimal () {
    echo "$(("$1"#"$2"))"
}
to_decimal 16 ff

The function to_decimal converts the number "$2" in base "$1" to decimal. The parser fails to recognize this instruction.

fakuivan avatar Jul 19 '19 23:07 fakuivan

Thanks for reporting this issue. It seems to be a grammar issue.

I create an issue: tree-sitter/tree-sitter-bash#62

skovhus avatar Sep 23 '19 19:09 skovhus

In my version of bash I actually get an error here:

"line 3: "16"#"ff": syntax error: operand expected (error token is ""16"#"ff"")"
$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.

skovhus avatar Mar 04 '20 10:03 skovhus

This seems to have been fixed in the newer version of the grammar

skovhus avatar Nov 25 '22 13:11 skovhus