-
Notifications
You must be signed in to change notification settings - Fork 788
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
fix: asdf info
show BASH_VERSION & all asdf envs
#1513
Conversation
d36e835
to
1151fef
Compare
lib/commands/command-info.bash
Outdated
@@ -4,9 +4,13 @@ | |||
|
|||
info_command() { | |||
printf "%s:\n%s\n\n" "OS" "$(uname -a)" | |||
printf "%s:\n%s\n\n" "SHELL" "$($SHELL --version)" | |||
printf "%s:\n%s\n\n" "SHELL" "Bash $BASH_VERSION" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use a non-Bash shell as a login shell and the existing behaviour works as expected. I understand we might want to know the BASH_VERSION as well, but knowing the login Shell is just as useful a debugging mechanism.
Regarding
$SHELL --version is too verbose
I would argue when people provide this information we want the more verbose output. Bash itself being more verbose than other shells is a Bash-ism.
Perhaps we can better handle failures with $SHELL
and then also add $BASH_VERSION
separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use a non-Bash shell as a login shell and the existing behaviour works as expected.
Ohh, oops what I said is only true for interactive logins I believe.
I would argue when people provide this information we want the more verbose output. Bash itself being more verbose than other shells is a Bash-ism.
What part of the information is useful? All lines except the first are license boilerplate and the stuff in the target triple is covered by uname -a
Perhaps we can better handle failures with $SHELL and then also add $BASH_VERSION separately?
If you still don't prefer $BASH_VERSION
, then I'll just quote "$SHELL"
and we can leave it at that. I also opened an issue in Shellcheck koalaman/shellcheck#2724 so hopefully this kind of stuff gets caught in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, oops what I said is only true for interactive logins I believe.
Right, well asdf info
was created for ease of sharing data for Issues/PRs in the repo. It is expected to be used in an interactive shell. Uses for scripting or non-interactive environments will eventually fall under a particular global flag (tentatively --porcelain
) and so is not a goal of the current implementation.
What part of the information is useful? All lines except the first are license boilerplate and the stuff in the target triple is covered by
uname -a
In my Nushell setup, $($SHELL --version)
gives me just my Nushell version number, nothing else. $BASH_VERSION
while also useful information, won't share my current Shell information in asdf info
. That information about my Nushell version is lost. This is useful information for us to debug with during Issues which asdf info
was created for ease of sharing with.
As I said, $BASH_VERSION
is useful as well, so seeing it as an addition to $($SHELL --version)
is welcome.
Removal of $($SHELL --version)
results in a loss of information.
So adding $BASH_VERSION
is welcome 👍
Better error handling of $($SHELL --version)
is also welcome, but it is preferred to keep it. The --version
verbosity is useful with non-Bash shells, like Nushell. It might be noisy with Bash, but that's an acceptable outcome. If you want to special case Bash, then sure, but non-Bash should use --version
I hope that clarifies things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see - using $SHELL
is important and the fact that it potentially invokes a different shell didn't register with me. I'll leave it in like you say and add $BASH_VERSION
since we don't want to loose information
lib/commands/command-info.bash
Outdated
printf "%s:\n%s\n\n" "ASDF VERSION" "$(asdf_version)" | ||
printf "%s:\n%s\n\n" "ASDF ENVIRONMENT VARIABLES" "$(env | grep -E "ASDF_DIR|ASDF_DATA_DIR|ASDF_CONFIG_FILE|ASDF_DEFAULT_TOOL_VERSIONS_FILENAME")" | ||
printf '%s\n' 'ASDF ENVIRONMENT VARIABLES:' | ||
printf 'ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=%s\n' "${ASDF_DEFAULT_TOOL_VERSIONS_FILENAME-(not set)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although not actually set, the default is .tool-versions
, so printing that it isn't set might be confusing. I guess this could be raised as a separate issue to actually set ASDF_DEFAULT_TOOL_VERSIONS_FILENAME
to the default .tool-versions
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You bring up a good point - these variables are labeled under ENVIRONMENT VARIABLES:
, yet they may not be env vars set by the user (only internally by asdf). And, I think like you mention, ASDF_DEFAULT_TOOL_VERSIONS_FILENAME
isn't set internally by asdf like the others, causing more confusion.
How does it sound to print INTERNAL VARIABLES:
, to make it clear that these variables aren't the same values as the environment variables the user passed in? In a separate issue I can set ASDF_DEFAULT_TOOL_VERSIONS_FILENAME
like we do with the other variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds like a good path forward, let's do that, thanks.
1151fef
to
a79a39a
Compare
b133f5d
to
570ca0a
Compare
I made those changes and also removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
asdf info
asdf info
show BASH_VERSION & all asdf envs
These changes make two fixes with the
info
subcommand:Use
$BASH_VERSION
for info about the current version of Bash because:$SHELL --version
is too verbose$SHELL
breaks when Bash is installed in a location that contains spaces (ShellCheck misses this because it seems it hard-codesSHELL
as an exception)$SHELL
breaks when a login shell other than Bash is usedChange printing of environment variables so that
Sample Output