Updated get_toolchain, it now retrieves active toolchain.#124
Open
ateraz13 wants to merge 1 commit into
Open
Conversation
|
Hi! What status of this PR, could you merge it? |
|
One issue with the current approach, plus a suggestion for a more The current diff can double-output on older rustup function get_toolchain {
rustup show | sed -nr 's/(.*) \(default\)/\1/p' | head -n 1
rustup show active-toolchain | awk '{print $1}'
}If we keep the rustup-based approach, the old line should be replaced, I guess, like: function get_toolchain {
rustup show active-toolchain | awk '{print $1}'
}But I guess better way try to resolve via LUA_FILTER="$HOME/.local/bin/rustic-doc-filter.lua"
-function get_toolchain {
- rustup show | sed -nr 's/(.*) \(default\)/\1/p' | head -n 1
-}
if [ "$1" = "" ] || [ "$1" = "--help" ]; then
MY_NAME="$(basename "$0")"
@@
if [ "$DEST_DIR" = "" ]; then
LIBRARY="$1"
- TARGET="$(get_toolchain)"
-
- ## Users can change the location of the rustup directory
- RUSTUP_HOME="${RUSTUP_HOME:-$HOME/.rustup}"
- ## Set
- DOC_PATH="$RUSTUP_HOME/toolchains/$TARGET/share/doc/rust/html/$LIBRARY"
+
+ ## Resolve the active toolchain's documentation directory directly via
+ ## rustc. This avoids parsing `rustup show` (whose output format changed:
+ ## the default toolchain is now tagged "(active, default)" instead of
+ ## "(default)") and also works for rustup-less, distro-packaged Rust.
+ SYSROOT="$(rustc --print sysroot)"
+ if [ -z "$SYSROOT" ]; then
+ echo "rustic-doc: could not determine rustc sysroot; is rustc on PATH?" >&2
+ exit 1
+ fi
+ DOC_PATH="$SYSROOT/share/doc/rust/html/$LIBRARY"
DEST_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/emacs/rustic-doc/$LIBRARY"
echo "Generating org files in: $DEST_DIR"
fiI could to open this as an alternative commit if you'd prefer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As per this issue, this pull requests updates the function which retrieves the active toolchain name as the previous approach is now outdated.