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 pythonicif java_path.
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 variablejava_path
(without the $), the variable automatically gets discarded at the end of the scope and does not need an explicitdel
.Replaced
if len(java_path) > 0
by the equivalent but more pythonicif java_path
.