Skip to content

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