Skip to content

refactor: public config variable naming changes #678

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

Merged
merged 15 commits into from
Apr 12, 2022
Merged

Conversation

scop
Copy link
Owner

@scop scop commented Jan 2, 2022

Implementation of variable naming changes discussed in #537 and #539

@scop scop marked this pull request as draft January 2, 2022 10:02
@scop
Copy link
Owner Author

scop commented Jan 2, 2022

Here's a few initial bits to start the work and to see how it'd look like.

This does not address the publicity part yet; arguably at least the _comp_test_* env state saving variables should be marked as private the way we end up wanting private ones to be marked.

This also does not mark any of the changes implemented yet as breaking even though strictly speaking, the xinetd and tar ones kind of would be. But those were never intended to be user settable under normal operation, and I doubt renaming them would cause any real world problems. Then again if we end up making some "really" breaking changes elsewhere which would warrant major version bump per semver, we could mark these as such as well.

@scop
Copy link
Owner Author

scop commented Apr 9, 2022

Should be rebased on top of #728 when that's in.

scop added 12 commits April 10, 2022 14:06
This was never intended to be a public user settable variable, but
exists just for test suite mocking purposes.
This is not intended for users to set in order to control completion
behavior, but rather for internal/dev-like testing. Therefore
`_comp_cmd_*` seems more appropriate.
For consistency with other internal state variables.
For consistency. Previous names were `BASHCOMP_*`, but that prefix is on
its way out.
The old variable name is still used as the (undocumented) fallback. It
is now made sure to be at the default in the test suite, too.
The old name still serves as the (undocumented) fallback.

While at it, verify both names are at their defaults for tests.
The old name still serves as the (undocumented) fallback.
The old name still serves as the (undocumented) fallback.
`COMP_TAR_INTERNAL_PATHS` still serves as the (undocumented) fallback.
`COMP_KNOWN_HOSTS_WITH_HOSTFILE` still serves as the (undocumented)
fallback.
`COMP_KNOWN_HOSTS_WITH_AVAHI` still serves as the (undocumented)
fallback.
@scop scop force-pushed the refactor/variable-renames branch from fdf8f55 to 2070c2a Compare April 10, 2022 11:16
@scop scop changed the base branch from master to docs/markdown April 10, 2022 11:18
@scop scop changed the title Namespacing/publicity variable naming changes refactor: public config variable naming changes Apr 10, 2022
scop added 3 commits April 10, 2022 14:41
Per naming guideline for non-local internal variables.

#539 (comment)
Per naming guideline for non-local internal variables.

#539 (comment)
Per naming guideline for non-local internal variables.

#539 (comment)
@scop
Copy link
Owner Author

scop commented Apr 10, 2022

This is now in sync with the current proposal at #539 (comment). Target branch is docs/markdown, with the intent that this will be merged to master after the markdown branch is in, not to the markdown branch before that.

Therefore draft status for now, although I consider this complete for changes touching public configuration/control variables, internal ones should be done in another PR to keep size at bay.

Base automatically changed from docs/markdown to master April 10, 2022 16:54
@scop scop marked this pull request as ready for review April 10, 2022 16:54
# `COMP_KNOWN_HOSTS_WITH_HOSTFILE' is set to an empty value.
if [[ -n ${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1} ]]; then
# `BASH_COMPLETION_KNOWN_HOSTS_WITH_HOSTFILE' is set to an empty value.
if [[ -n ${BASH_COMPLETION_KNOWN_HOSTS_WITH_HOSTFILE-${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1}} ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if [[ -n ${BASH_COMPLETION_KNOWN_HOSTS_WITH_HOSTFILE-${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1}} ]]; then
if [[ ${BASH_COMPLETION_KNOWN_HOSTS_WITH_HOSTFILE-${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1}} ]]; then

I think this is more consistent with other cases.

# passwordless access to the remote repository
if [[ -n ${COMP_CVS_REMOTE:-} ]]; then
if [[ -n ${BASH_COMPLETION_CMD_CVS_REMOTE-${COMP_CVS_REMOTE-}} ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if [[ -n ${BASH_COMPLETION_CMD_CVS_REMOTE-${COMP_CVS_REMOTE-}} ]]; then
if [[ ${BASH_COMPLETION_CMD_CVS_REMOTE-${COMP_CVS_REMOTE-}} ]]; then

@@ -634,7 +635,8 @@ _filedir()
IFS=$'\n'

# Try without filter if it failed to produce anything and configured to
[[ -n ${COMP_FILEDIR_FALLBACK-} && -n $arg && ${#toks[@]} -lt 1 ]] && {
[[ ${BASH_COMPLETION_FILEDIR_FALLBACK-${COMP_FILEDIR_FALLBACK-}} &&
-n $arg && ${#toks[@]} -lt 1 ]] && {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
-n $arg && ${#toks[@]} -lt 1 ]] && {
$arg && ${#toks[@]} -lt 1 ]] && {

@@ -623,7 +623,8 @@ _filedir()
# the fallback condition with the "plus" dirs.
local opts=(-f -X "$xspec")
[[ $xspec ]] && plusdirs=(-o plusdirs)
[[ ${COMP_FILEDIR_FALLBACK-} || -z ${plusdirs-} ]] ||
[[ ${BASH_COMPLETION_FILEDIR_FALLBACK-${COMP_FILEDIR_FALLBACK-}} ||
-z ${plusdirs-} ]] ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
-z ${plusdirs-} ]] ||
! ${plusdirs-} ]] ||

It seems there are more cases [[ ! $word ]] (5 cases in bash_completion) than [[ -z $word ]] (2 cases). Another instance of -z is in line bash_completion:1990 (_cd).

@scop scop merged commit 8181dab into master Apr 12, 2022
@scop scop deleted the refactor/variable-renames branch April 12, 2022 15:43
@scop
Copy link
Owner Author

scop commented Apr 12, 2022

Thanks for having a look and good point on the suggestions. However, we have a lot of similar cases in completions/*, so it seems it'd be good to address them in one go and add a style guide entry for it, too. I opened #740 for that and chose to leave those changes out from this one.

@akinomyoga
Copy link
Collaborator

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.

2 participants