Comments (3)
This may be a similar issue, or my own misunderstanding of bashlex:
>>> bashlex.parse('DOCKER_BUILDTAGS+=" $tag"')
[CommandNode(parts=[AssignmentNode(parts=[ParameterNode(pos=(20, 24) value='tag')] pos=(0, 25) word='DOCKER_BUILDTAGS+= $tag')] pos=(0, 25))]
I expected the following output instead:
[CommandNode(parts=[AssignmentNode(parts=[ParameterNode(pos=(20, 24) value='tag')] pos=(0, 25) word='DOCKER_BUILDTAGS+=" $tag"')] pos=(0, 25))]
from bashlex.
@d4g33z that is unrelated to this issue and bashlex lexes your example correctly. This is how bash interprets that:
$ tag="world"
$ echo hello=" $tag"
hello= world
$
In other words, echo
gets one argument with $tag
substituted for the value of the tag
variable and the quotes removed. The "
quotes are needed so that you can have whitespace in one argument (otherwise echo hello= $tag
would pass two arguments to echo
: hello=
and $tag
, which it would print separated by 1 space instead of however many I put in there, and that's just because of how echo
works, it prints arguments separated by a space), they are stripped by bash before passing the args to the command being called.
from bashlex.
Sorry to hijack the issue. I'll have to revisit parsing += assignments that concatenate strings with white space.
Thanks, it's a great library.
from bashlex.
Related Issues (20)
- bashlex is creating python files at import time HOT 4
- Parsing fails for *some* list nodes inside command substitution nodes.
- space at the end of line - parse error HOT 3
- importing the ABCs from 'collections' instead of from 'collections.abc' error HOT 3
- [request] Ship wheels too HOT 4
- "a\\ \n" is not treated the same as "a\\\n"
- Variable names cannot have numbers in them
- Airthmetic Command Implementation HOT 3
- [request] Add support for local, global, and export HOT 3
- If statements only have support for conditional commands (COND_CMD)
- Multiple new lines at end of file HOT 3
- backslash newline fails
- New release - When ? HOT 2
- Issues with parsing && and ||
- Parsing scripts with arrays HOT 2
- add unimplemented nodes to AST instead of raising exceptions HOT 3
- add support for using unimplemented nodes for array assignment HOT 3
- case statement parsing?
- How to check if a line is a complete bash command or not? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bashlex.