-
Notifications
You must be signed in to change notification settings - Fork 72
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
Overhaul #112
base: master
Are you sure you want to change the base?
Overhaul #112
Conversation
Thanks for the contribution, @tbodt! Could you provide a quick writeup on the overhaul? For example, an explanation of how the state file is used will be super helpful. Thanks! |
The basic idea is: bash includes a lot of builtins that dump out shell state (variables, functions, completions) in the same syntax as is used to create them, so if you source a script that defines a lot of functions and then run the dump commands, you can run any of those functions again by restarting bash and feeding in the whole script again. Storing the state in a file is something i'm not entirely happy with since it's so easy to forget to delete it. I originally was going to store it in memory, but passing it between the three processes involved was a real pain and needed to create temporary files anyway because the fish psub function apparently blocks until the input command completes which means the output had better fit in a pipe buffer or you're going to need a file, and even though i got it to work it was a major performance problem because pushing around half a kilobyte in a shell variable and then sending it into the script file in the form of fish \xHH escapes was not fast. There's unexplored design space here but i just wanted to get it working finally so i made a file. Ultimately fish (and bash) support for non-named pipes is pretty disappointing. Possible new issue: from the point of view of the script, the bash pid will change between function invocations, and this will break some script out there as a consequence of hyrum's law. I don't have any ideas for fixing this short of another overhaul to write basically an RPC server in bash. Well that could be pretty fun actually now that i think about it... |
script_lines.append(comment(b'updating alias %s=%s -> %s' % (k, v1, v))) | ||
else: | ||
continue | ||
script_lines.append(b'alias %s %s' % (k, v)) |
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.
Aliases probably need to be run through bass
as well, don't they? At least, I'm currently encountering an alias that contains bash code.
Major overhaul to support functions. With a bit more work it can probably do completions. Also should fix all the quoting issues.
Not very well field tested yet, but passes all the tests in the repo.
Needs a pass for python 2 compat. I can't really do this easily since my Linux distro has deleted python 2 entirely.