-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shasta extension for libbash #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! Two big questions:
- Is this backwards compatible?
- Can we add some text in README or another document that really describes the interplay between dash and abash shasta? And how should one navigate this repo if they need to use one of the two only?
The tests for dash still pass, both in shasta and my branch of PaSh with the bash changes merged in, which is a good sign.
If you’re using the library, the only difference is whether you import from |
I now saw your overall comment, that is great, thanks a lot! The documentation plan sounds perfect! Regarding the changes to AST nodes, could we have a Once we get these merged we should also make a new major release of shasta so that downstream projects don't really break. Thank you so much for the very diligent work here @BolunThompson !! |
f43b1cc
to
cd36e5b
Compare
Somewhat of a bad practice but, otherwise, every class that calls string_of_arg would have to have a bash_mode field to change behavior for it
Currently, bash mode interprets all characters as CArgChar, relying on the user to manually expand as necessary. This breaks string_of_arg, since it escapes all '$' CArgChars, assuming that it shouldn't be interprted as variable interpolation when it's pretty printed. This disables escaping in bash mode.
Only requires adding a few "from __future__ import annotations" to allow type hints like list[int] to be used instead of List[int]
Type hinting is only being used for documentation at this time, but it's good to use specific and syntactically correct type hints. However, to use the type checker in a useful way, you'd have to use isinstance instead of string tags for the AstNodes (or an equivalent "is_type(*AstNode)" function).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks great, what are peoples' thoughts on the libbash dependency?
pyproject.toml
Outdated
@@ -14,6 +14,7 @@ classifiers = [ | |||
"License :: OSI Approved :: MIT License", | |||
"Operating System :: POSIX", | |||
] | |||
dependencies = ["libbash"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am scared of this dependency because I am afraid of dependency hell (either due to circular dependencies or because a downstream program (like PaSh) might want a different version of one and the other).
I guess we don't have this issue with libdash because we use a JSON object? Could we do sth similar here (maybe in a different PR?)? Alternatively, is my fear irrational and we just have to bite the bullet and do it? I am wondering whether someone could use shasta without needing to import libbash and whatever that includes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with your intuition — although I can’t think of an obvious scenario that would cause a problem. The code right now doesn’t actually import anything from libbash (in a runtime capacity) except a handful of enums, so I can easily remove the dependency after copying those over (± some minor changes).
See binpash#5 (comment) For tests, libbash (and now libdash) are dev dependencies.
That’s weird — the tests sometimes pass on my machine, and I’ve somehow messed up the state of my local git repo, so I‘ll fix this in a day or two. |
No rush! |
See binpash#5 (comment) For tests, libbash (and now libdash) are dev dependencies.
Caused very annoying bug in that bash_node was being set in the bash parsing code, but then dash parsing code is called internally, then bash parsed objects print out in dash mode. Side note: this is why they teach that globals are bad in intro to CS!
Signed-off-by: Bolun Thompson <[email protected]>
Should be ready to review now! I suspect shasta converts libbash into shasta incorrectly for a few edge cases because they compare roundtrip 1 and 2 (ex: there was a bug where shasta ignored whether a case node was supposed to fall through or not). Comparing the outputs of the original script and the roundtrips on valid bash tests could catch these (another issue?). |
Signed-off-by: Bolun Thompson <[email protected]>
Signed-off-by: Bolun Thompson <[email protected]>
Do you mean that to catch these bugs we would need to compare the original script and the output after the roundtrip? instead of roundtrip 1 vs roundtrip 2? I think this would catch some bugs but would also make things a bit flaky because our pretty printing would affect tests (even though semantically equivalent). In any case, we should look at this in a different PR :) |
That’d work, but as you said it’d be finicky. #6 is what I meant to say. |
Integrates @sethsabar’s shasta for libbash work into the mainline. The tests pass (besides one bash expected failure).