bashlex icon indicating copy to clipboard operation
bashlex copied to clipboard

[request] Add support for local, global, and export

Open BlankCanvasStudio opened this issue 3 years ago • 3 comments

If an assign statement is used after local, global, and export it is treated as a word node, not an assignment node.

BlankCanvasStudio avatar Jan 04 '22 17:01 BlankCanvasStudio

Agree. I often will declare functions as:

foo() {
  local key="$1"
  local value="$2"
  # Do the "needful"
}

curtisforrester avatar Nov 18 '22 15:11 curtisforrester

I was unable to reproduce an issue with local, global, or export using version 0.18.

samlikins avatar May 17 '23 11:05 samlikins

In a Python interactive session (using bashlex v0.18):

Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bashlex
>>> bashlex.parse('local key=1')
[CommandNode(parts=[WordNode(parts=[] pos=(0, 5) word='local'), WordNode(parts=[] pos=(6, 11) word='key=1')] pos=(0, 11))]
>>> bashlex.parse('global key=1')
[CommandNode(parts=[WordNode(parts=[] pos=(0, 6) word='global'), WordNode(parts=[] pos=(7, 12) word='key=1')] pos=(0, 12))]
>>> bashlex.parse('export key=1')
[CommandNode(parts=[WordNode(parts=[] pos=(0, 6) word='export'), WordNode(parts=[] pos=(7, 12) word='key=1')] pos=(0, 12))]

samlikins avatar May 17 '23 12:05 samlikins