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

make editor selection aware of VISUAL env variable #51991

Closed
wants to merge 1 commit into from

Conversation

zmyrgel
Copy link

@zmyrgel zmyrgel commented Feb 9, 2019

Vault editor should prefer editor set in VISUAL env variable and only then fallback to EDITOR.

SUMMARY

When ansible-vault command opens editor it first looks for editor set in EDITOR env variable and falls back to vi if EDITOR is not set.
This fixes it so that it first looks for editor in set in VISUAL env variable, then in EDITOR and finally falls back to vi.

For background info:
https://unix.stackexchange.com/questions/4859/visual-vs-editor-what-s-the-difference

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

parsing

ADDITIONAL INFORMATION

Following should open ansible vault file in emacs after the change.

VISUAL=emacs ansible-vault edit </path/to/vault/file>

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 core_review In order to be merged, this PR must follow the core review workflow. feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. small_patch support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Feb 9, 2019
@sivel
Copy link
Member

sivel commented Feb 12, 2019

This will require a changelog fragment in changelog/fragments as well.

@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Feb 12, 2019
@ansibot ansibot added the support:community This issue/PR relates to code supported by the Ansible community. label Feb 13, 2019
@ansibot
Copy link
Contributor

ansibot commented Feb 13, 2019

The test ansible-test sanity --test changelog [explain] failed with 1 error:

changelogs/fragments/vault-editor-env-fix.yml:0:0: (WARNING/2) Inline interpreted text or phrase reference start-string without end-string.

click here for bot help

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Feb 13, 2019
@mattclay mattclay added the ci_verified Changes made in this PR are causing tests to fail. label Feb 14, 2019
Vault editor should prefer editor set in VISUAL env variable and only then fallback to EDITOR.

For more background, check:
https://unix.stackexchange.com/questions/4859/visual-vs-editor-what-s-the-difference
@ansibot
Copy link
Contributor

ansibot commented Feb 17, 2019

The test ansible-test sanity --test changelog [explain] failed with 1 error:

changelogs/fragments/vault-editor-env-fix.yml:0:0: (WARNING/2) Inline interpreted text or phrase reference start-string without end-string.

click here for bot help

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 27, 2019
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Apr 16, 2019
@mattclay mattclay added the ci_verified Changes made in this PR are causing tests to fail. label Apr 17, 2019
Comment on lines +1097 to +1099
env_editor = os.environ.get('VISUAL')
if not env_editor:
env_editor = os.environ.get('EDITOR', 'vi')
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we have used EDITOR historically, we should not change the default and need to start with EDITOR as the default. This precedence may not make sense, though, and we may need to add a config option to control this.

Suggested change
env_editor = os.environ.get('VISUAL')
if not env_editor:
env_editor = os.environ.get('EDITOR', 'vi')
env_editor = os.environ.get('EDITOR', os.environ.get('VISUAL', 'vi'))

@samdoran
Copy link
Contributor

needs_info

@ansibot ansibot added the needs_info This issue requires further information. Please answer any outstanding questions. label Jul 17, 2020
@ansibot
Copy link
Contributor

ansibot commented Aug 18, 2020

@zmyrgel This pullrequest is waiting for your response. Please respond or the pullrequest will be closed.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Sep 19, 2020

@zmyrgel You have not responded to information requests in this pullrequest so we will assume it no longer affects you. If you are still interested in this, please create a new pullrequest with the requested information.

click here for bot help

@ansibot ansibot closed this Sep 19, 2020
@ansible ansible locked and limited conversation to collaborators Oct 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 ci_verified Changes made in this PR are causing tests to fail. feature This issue/PR relates to a feature request. needs_info This issue requires further information. Please answer any outstanding questions. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_contributor This PR is the first contribution by a new community member. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants