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

Update set-java-home.xsh #216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nd-net
Copy link

@nd-net nd-net commented Oct 24, 2023

The process substitution operator $() returns output with universal new lines which must be stripped - $(asdf which java) returns the path name including a trailing \n; feeding that to realpath gives the error message "No such file or directory".

Replaced the temporary environment variable $java_path with a local java variable java_path (without the $), the variable automatically gets discarded at the end of the scope and does not need an explicit del.

Replaced if len(java_path) > 0 by the equivalent but more pythonic if java_path.

The [process substitution operator $() returns output with universal new lines][1] which must be stripped - $(asdf which java) returns the path name including a trailing \n; feeding that to realpath gives the error message "No such file or directory".

Replaced the temporary environment variable `$java_path` with a local java variable `java_path` (without the $), the variable automatically gets discarded at the end of the scope and does not need an explicit `del`.

Replaced `if len(java_path) > 0` by the equivalent but more [pythonic][2] `if java_path`.

[1]: https://github.com/anki-code/xonsh-cheatsheet#3-the-process-substitution-operator--returns-output-with-universal-new-lines
[2]: https://docs.python.org/3/library/stdtypes.html#truth-value-testing
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.

1 participant