Skip to content
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

ASH_SESSION_ID set but __ash_* functions not defined #4

Closed
sjjf opened this issue Jul 19, 2018 · 3 comments
Closed

ASH_SESSION_ID set but __ash_* functions not defined #4

sjjf opened this issue Jul 19, 2018 · 3 comments

Comments

@sjjf
Copy link
Contributor

sjjf commented Jul 19, 2018

I run ash on my Ubuntu desktop, with a large collection of gnome-terminal sessions running across multiple windows, all started from a single terminal. ash works nicely in the first session, but later sessions somehow inherit the ASH_SESSION_ID value in their environment but not the function definitions - simply checking for the session id and bailing doesn't result in a usable environment.

I have a fix for this issue, and I'll submit a pull request for it - I'm not sure if there's a better approach, though. Looking at the other open issue at the moment (#3) it's possible that this is something that happens more broadly than just my environment . . .

@barabo
Copy link
Owner

barabo commented Jul 19, 2018

After applying your proposed fix, does the session ID get updated?

@sjjf
Copy link
Contributor Author

sjjf commented Jul 20, 2018

The session id stays the same until I log out (thereby killing the initial terminal session, with the original bash process that set up and exported the ASH_SESSION_ID value).

I looked into this more deeply and I think it's caused by the fact that the ASH_* env variables are exported, but the functions aren't - child terminal sessions see the environment set up for ash but they don't have the core functions defined, so they fail miserably. Either exporting the functions, or ensuring that all the environment setup is limited to a single process should make it work (I.e. don't export /anything/, or export everything ash needs to work). My proposed fix just works around the issue.

I guess what approach you take depends on how you want to define a "session" - does that mean a single bash process, a bash process and all its children, a single login session (which might require a different mechanism for exporting the session information?), or something else? I can see either a single process or all its children both being entirely valid models, but it's not something I think matters all /that/ much, as long as the whole implementation is consistent.

@barabo
Copy link
Owner

barabo commented Jul 25, 2018

A fix was merged. The net result of this is that when a new terminal is launched from an existing one (where the ASH_SESSION_ID has been exported), the launched terminals will share the same session ID. This stretches the definition of what a session should be (in my mind), but if it's a useful feature that's fine.

@barabo barabo closed this as completed Jul 25, 2018
tyler-ham added a commit to tyler-ham/advanced-shell-history that referenced this issue Dec 24, 2020
ASH_SESSION_ID seems to be set in some cases where the file hasn't
actually been sourced, so explicitly check for the functions being
defined before bailing.

This addresses issue barabo#4 in zsh the same way it was addressed in bash
via PR barabo#5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants