Skip to content

Commit ed1eb76

Browse files
committed
Warn when curl or jq is missing and assume sed always exists.
1 parent 7fb61fe commit ed1eb76

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

bash_completion

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/bin/bash -e
22

3+
if ! command -v curl > /dev/null; then
4+
>&2 echo "WARNING: Could not find curl ( https://curl.haxx.se/ )."
5+
fi
6+
7+
if ! command -v jq > /dev/null; then
8+
>&2 echo "WARNING: Could not find jq ( https://stedolan.github.io/jq/ )."
9+
fi
10+
311
__cppsm_complete() {
412
local IFS=$' \t\n'
513
COMPREPLY=()
@@ -17,24 +25,22 @@ __cppsm_complete() {
1725
COMPREPLY=($(compgen -W "equipment requires" -- "$CURRENT"))
1826
;;
1927
clone)
20-
if command -v jq > /dev/null && command -v curl > /dev/null && command -v sed > /dev/null; then
28+
if command -v jq > /dev/null && command -v curl > /dev/null; then
2129
# shellcheck disable=SC2207
2230
COMPREPLY=($(curl -s "https://api.github.com/search/repositories?q=topic:cppsm+${CURRENT##*/}" | \
2331
jq '.items | .[] | .ssh_url'))
2432
fi
2533
;;
2634
equipment|requires)
27-
if command -v jq > /dev/null && command -v curl > /dev/null && command -v sed > /dev/null; then
35+
if command -v jq > /dev/null && command -v curl > /dev/null; then
2836
# shellcheck disable=SC2207
2937
COMPREPLY=($(curl -s "https://api.github.com/search/repositories?q=topic:cppsm+${CURRENT##*/}" | \
3038
jq '.items | .[] | .clone_url'))
3139
fi
3240
;;
3341
https:*.git|git*.git)
34-
if command -v sed > /dev/null; then
35-
# shellcheck disable=SC2207
36-
COMPREPLY=($(git ls-remote --heads "$PREVIOUS" | sed -e 's#[^ ]*\s*refs/heads/##g'))
37-
fi
42+
# shellcheck disable=SC2207
43+
COMPREPLY=($(git ls-remote --heads "$PREVIOUS" | sed -e 's#[^ ]*\s*refs/heads/##g'))
3844
;;
3945
*)
4046
;;

0 commit comments

Comments
 (0)