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

Remove execution-specific code in sourcing-only .sh files #1436

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

EliahKagan
Copy link
Contributor

@EliahKagan EliahKagan commented Jun 30, 2024

Some of the .sh script files are only meant ever to be sourced and not to be executed. These are already correctly not marked executable, but some of them contained code that would only be proper for scripts that are actually run, and not for scripts that are only sourced:

  • One contained a #! line, which this removes because it falsely indicated an intent to be executed, and because it was not effective even in principle when sourcing the script.

  • Two contained set -eu commands affecting the behavior of the running interpreter, which were redundant because the script for which they are helpers already runs such a command. If they are later sourced into other scripts (a use for which they are not intended and would probably require further modification), those other scripts might not have these set commands, but in that case those commands' behavior would probably not be wanted.

This also adds "Must be sourced into the main journey test" comments at the top of .sh files to which they apply, mirroring the presence of such comments in other such files. Besides consistency, this has the advantage of making clear what all the scripts that are meant only for sourcing are being used for.


I was originally going to include this in #1435, but it doesn't overlap with the changes there, is not essential to them, probably makes sense to evaluate separately, and could overcomplicate #1435 given the other subtlety raised there relating to which archives that PR should regenerate. So I've opened this separate PR instead.

Some of the .sh script files are only meant ever to be sourced and
not to be executed. These are already correctly not marked
executable, but some of them contained code that would only be
proper for scripts that are actually run, and not for scripts
that are only sourced:

- One contained a #! line, which this removes because it falsely
  indicated an intent to be executed, and because it was not
  effective even in principle when sourcing the script.

- Two contained `set -eu` commands affecting the behavior of the
  running interpreter, which were redundant because the script for
  which they are helpers already runs such a command. If they are
  later sourced into other scripts (a use for which they are not
  intended and would probably require further modification), those
  other scripts might not have these `set` commands, but in that
  case those commands' behavior would probably not be wanted.

This also adds "Must be sourced into the main journey test"
comments at the top of .sh files to which they apply, mirroring
the presence of such comments in other such files. Besides
consistency, this has the advantage of making clear what all the
scripts that are meant only for sourcing are being used for.
Copy link
Owner

@Byron Byron left a comment

Choose a reason for hiding this comment

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

Thanks a lot for cleaning this up!

@Byron Byron merged commit 8a2f6b7 into Byron:main Jul 1, 2024
19 checks passed
@EliahKagan EliahKagan deleted the script-helpers branch July 1, 2024 07:45
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