From c2155b770d7dcff16da57a5d18f1e9c58b5990d1 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Fri, 16 Sep 2022 16:41:47 -0500 Subject: [PATCH] [completions] Handle errors thrown by `gh` `gh` doesn't write its errors to stderr and doesn't exit with a non-zero status code in case of failure. The completions are short enough that buffering them isn't a huge deal. --- share/completions/gh.fish | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/share/completions/gh.fish b/share/completions/gh.fish index 13eca1609..22276ec94 100644 --- a/share/completions/gh.fish +++ b/share/completions/gh.fish @@ -1 +1,6 @@ -gh completion --shell fish 2>/dev/null | source +# gh, at least as of version 1.17.5, does not write errors to stderr, causing +# `checks/completions.fish` to fail if the `gh-completion` module is missing. +# It also does not exit with a non-zero error code, making this harder than it needs to be :( +set completion "$(gh completion --shell fish)" +string match -rq '^Error' -- $completion && return -1 +echo $completion | source