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

Explicitly check for the __ash_* functions before bailing. #5

Merged
merged 1 commit into from
Jul 25, 2018

Conversation

sjjf
Copy link
Contributor

@sjjf sjjf commented Jul 19, 2018

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.

Addresses issue #4

Copy link
Owner

@barabo barabo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be interested to know what leads to this situation for you.

Also, please use grep -q instead of grep -s, since the latter only suppresses error messages whereas the former suppresses all output.

Thanks!

# Under some circumstances ASH_SESSION_ID can be set but the functions not
# defined properly, so we explicitly check for the __ash_* functions before
# returning here.
if [[ -n "${ASH_SESSION_ID}" ]]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. How does this look?
[[ -n "${ASH_SESSION_ID}" ]] && declare -F __ash_log | grep -q . && return

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.
@sjjf sjjf force-pushed the check-functions branch from 1ba321e to e011cd2 Compare July 20, 2018 00:35
@sjjf
Copy link
Contributor Author

sjjf commented Jul 20, 2018

I log in, run a single gnome-terminal via the GUI, then I run a bunch more gnome-terminals from a script run on the command line in the original terminal. The environment variables are exported, but not the functions, so the subsequent terminals /think/ they're running an existing session but they don't have access to the functions.

Why is the function export at the end of the file commented out? If you're exporting the session id and so forth (particularly the PROMPT_COMMAND) isn't exporting the functions essential? Re-sourcing the definitions is a workaround for the lack of function exports, but given they're /there/ but commented out I'm assuming there was a reason for the change . . .

Copy link
Owner

@barabo barabo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@barabo barabo merged commit e9c705b into barabo:master Jul 25, 2018
tyler-ham added a commit to tyler-ham/advanced-shell-history that referenced this pull request 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

Successfully merging this pull request may close these issues.

2 participants