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

bash_it.sh: source reloader.bash without arguments for the default enabling #2096

Merged

Conversation

akinomyoga
Copy link
Contributor

Description

The recent change 23f9b74 has broken plugin/blesh. Because ble.sh now receives garbage arguments, it fails to interpret the arguments and cancels its loading.

  • First, it should be noted that source FILE without arguments will inherit the arguments of the caller context.
  • Originally, reloader.bash has been called without arguments for the current mechanism of enabling modules. The arguments have been only supplied for the legacy loading. However, now the arguments are always specified to reloader.bash and are inherited by descendant sources including the external configurations. The unwanted arguments are '' '' for the current mechanism of loading modules.

In this PR,

  • I explicitly specify an option to as source ble.sh --attach=prompt to override the arguments inherited by realoder.bash.
  • The arguments are specified to reloader.bash only for the leagcy loading.

Additionally, maybe we should separate the call of reloader.bash for the current enabling mechanism and the calls of reloader.bash for the legacy enabling as we have been doing originally before 23f9b74. I think the reason that they were originally separated is that these codes are considered deprecated. Mixing the up-to-date codes and the deprecated codes doesn't seem to be an improvement.

Motivation and Context

All the plugins and other modules in bash-it are supposed to be correctly loaded by bash-it. This change is required to prevent all source in bash-it and external configurations (called from reloader.bash and its descendants) from receiving unexpected arguments that were originally specified to reloader.bash. This becomes a problem when there is any configuration that interprets its arguments. This solves possible problems caused by these unexpected arguments. At least, this solves the problem that ble.sh fails to start with blesh plugin in the current master (187916d).

This is not related to any open issue as far as I know. The problem is introduced in master just five days ago by merge commit 23f9b74. I have also checked recent pull requests but could not find related ones.

How Has This Been Tested?

  • Only the blesh plugin is enabled (disabled any other plugins, aliases, completions).
  • The latest version of ble.sh (akinomyoga/ble.sh@5015cb5) is installed in $HOME/.local.
  • Use the following commands to see if ble.sh is correctly loaded.
$ bash --norc
$ export BASH_IT="/path/to/bash-it"
$ source "$BASH_IT/bash-it.sh"

Before the fix (i.e., the current master 187916d), the plugin produces the following error messages, and ble.sh is not enabled.

ble.sh: unrecognized argument ''
ble.sh: unrecognized argument ''
ble.sh: cancel initialization.

After the fix, the session normally starts without any error messages and with ble.sh being enabled correctly.

This PR may affect the arguments that other plugins, aliases, and completions receive, but will just make the behavior the one before the merge commit 23f9b74, so I don't think there will be any problems. Nevertheless, in principle, if there are any new plugins, aliases, or completions that assume the arguments '' '', they can be broken.

Screenshots (if appropriate):

The left panel shows the behavior in the current master (187916d) where ble.sh isn't enabled. The right panel shows the behavior after the fix where ble.sh is correctly loaded and working.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • If my change requires a change to the documentation, I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • If I have added a new file, I also added it to clean_files.txt and formatted it using lint_clean_files.sh.
  • I have added tests to cover my changes, and all the new and existing tests pass.

@akinomyoga akinomyoga force-pushed the plugin-blesh-workaround-reloader-change branch from 78960fa to ee85367 Compare February 19, 2022 08:17
Copy link
Member

@NoahGorny NoahGorny left a comment

Choose a reason for hiding this comment

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

Well done @akinomyoga
I really liked the amount of detail you posted, thank you!

@NoahGorny NoahGorny merged commit 1c8ad2c into Bash-it:master Feb 19, 2022
@akinomyoga akinomyoga deleted the plugin-blesh-workaround-reloader-change branch February 19, 2022 21:50
@akinomyoga
Copy link
Contributor Author

Thanks!

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.

None yet

2 participants