Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Fixed prompt_rust_version to avoid grep aliases #826

Merged
merged 4 commits into from Jul 10, 2018

Conversation

TheDan64
Copy link
Contributor

@TheDan64 TheDan64 commented May 5, 2018

Fixes #803

Copy link
Member

@dritter dritter left a comment

Choose a reason for hiding this comment

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

Thanks @TheDan64 for this PR.

@@ -1104,10 +1104,14 @@ prompt_root_indicator() {
# Print Rust version number
prompt_rust_version() {
local rust_version
rust_version=$(rustc --version 2>&1 | grep -oe "^rustc\s*[^ ]*" | grep -o '[0-9.a-z\\\-]*$')
rust_version=$(command rustc --version 2>&1)
Copy link
Member

Choose a reason for hiding this comment

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

This raises an error, if rustc is not installed. We should silence all errors here:
rust_version=$(command rustc --version 2>/dev/null)


if [[ -n "$rust_version" ]]; then
"$1_prompt_segment" "$0" "$2" "208" "$DEFAULT_COLOR" "Rust $rust_version" 'RUST_ICON'
"$1_prompt_segment" "$0" "$2" "208" "$DEFAULT_COLOR" "$rust_version" 'RUST_ICON'
Copy link
Member

Choose a reason for hiding this comment

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

This will make the tests fail. In #803 I removed the Rust, because this is more an identifier for this segment and a fallback icon. Therefore it should be the value for RUST_ICON. Or we should just update the tests for this segment.

@TheDan64
Copy link
Contributor Author

TheDan64 commented May 10, 2018

Thanks for the review; I silenced the missing rustc error and tried to fix the test. Any idea what's going on with the last broken test?

@dritter
Copy link
Member

dritter commented May 11, 2018

Hah. 🤦‍♂️ In our test we mock rustc. In the new code we avoid any wrapper scripts and call command rustc. So we need to find a good way to mock rustc anyways..

@dritter
Copy link
Member

dritter commented May 12, 2018

Just for the record: This PR is related to #632

dritter added a commit to dritter/powerlevel9k that referenced this pull request Jun 6, 2018
Conflicts were:
- test/segments/rust_version.spec and powerlevel9k.zsh-theme. Powerlevel9k#826
removes grep from parsing the rust version on next; Powerlevel9k#703 changes color
names.
@dritter dritter mentioned this pull request Jun 7, 2018
@bhilburn bhilburn merged commit 4df61d9 into Powerlevel9k:master Jul 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants