Skip to content

Commit

Permalink
fix: make compatible with ancient bash
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 9, 2025
1 parent cb1f7b4 commit 9e76a17
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 7 deletions.
6 changes: 5 additions & 1 deletion cli/assets/completions/usage.bash
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ _usage() {
return 0
}

shopt -u hostcomplete && complete -o nospace -o bashdefault -o nosort -F _usage usage
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
shopt -u hostcomplete && complete -o nospace -o bashdefault -o nosort -F _usage usage
else
shopt -u hostcomplete && complete -o nospace -o bashdefault -F _usage usage
fi
# vim: noet ci pi sts=0 sw=4 ts=4 ft=sh
6 changes: 5 additions & 1 deletion lib/src/complete/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ __USAGE_EOF__"#,
return 0
}}
shopt -u hostcomplete && complete -o nospace -o bashdefault -o nosort -F _{bin_snake} {bin}
if [[ "${{BASH_VERSINFO[0]}}" -eq 4 && "${{BASH_VERSINFO[1]}}" -ge 4 || "${{BASH_VERSINFO[0]}}" -gt 4 ]]; then
shopt -u hostcomplete && complete -o nospace -o bashdefault -o nosort -F _{bin_snake} {bin}
else
shopt -u hostcomplete && complete -o nospace -o bashdefault -F _{bin_snake} {bin}
fi
# vim: noet ci pi sts=0 sw=4 ts=4 ft=sh
"#
));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: lib/src/complete/bash.rs
expression: "complete_bash(&CompleteOptions\n{\n shell: \"bash\".to_string(), bin: \"mycli\".to_string(), cache_key:\n Some(\"1.2.3\".to_string()), spec: None, usage_cmd:\n Some(\"mycli complete --usage\".to_string()), include_bash_completion_lib:\n false,\n})"
expression: "complete_bash(&CompleteOptions\n{\n usage_bin: \"usage\".to_string(), shell: \"bash\".to_string(), bin:\n \"mycli\".to_string(), cache_key: Some(\"1.2.3\".to_string()), spec: None,\n usage_cmd: Some(\"mycli complete --usage\".to_string()),\n include_bash_completion_lib: false,\n})"
snapshot_kind: text
---
_mycli() {
Expand All @@ -27,5 +27,9 @@ _mycli() {
return 0
}

shopt -u hostcomplete && complete -o nospace -o bashdefault -o nosort -F _mycli mycli
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
shopt -u hostcomplete && complete -o nospace -o bashdefault -o nosort -F _mycli mycli
else
shopt -u hostcomplete && complete -o nospace -o bashdefault -F _mycli mycli
fi
# vim: noet ci pi sts=0 sw=4 ts=4 ft=sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,9 @@ __USAGE_EOF__
return 0
}

shopt -u hostcomplete && complete -o nospace -o bashdefault -o nosort -F _mycli mycli
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
shopt -u hostcomplete && complete -o nospace -o bashdefault -o nosort -F _mycli mycli
else
shopt -u hostcomplete && complete -o nospace -o bashdefault -F _mycli mycli
fi
# vim: noet ci pi sts=0 sw=4 ts=4 ft=sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: lib/src/complete/bash.rs
expression: "complete_bash(&CompleteOptions\n{\n shell: \"bash\".to_string(), bin: \"mycli\".to_string(), cache_key: None,\n spec: None, usage_cmd: Some(\"mycli complete --usage\".to_string()),\n include_bash_completion_lib: false,\n})"
expression: "complete_bash(&CompleteOptions\n{\n usage_bin: \"usage\".to_string(), shell: \"bash\".to_string(), bin:\n \"mycli\".to_string(), cache_key: None, spec: None, usage_cmd:\n Some(\"mycli complete --usage\".to_string()), include_bash_completion_lib:\n false,\n})"
snapshot_kind: text
---
_mycli() {
Expand All @@ -27,5 +27,9 @@ _mycli() {
return 0
}

shopt -u hostcomplete && complete -o nospace -o bashdefault -o nosort -F _mycli mycli
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
shopt -u hostcomplete && complete -o nospace -o bashdefault -o nosort -F _mycli mycli
else
shopt -u hostcomplete && complete -o nospace -o bashdefault -F _mycli mycli
fi
# vim: noet ci pi sts=0 sw=4 ts=4 ft=sh
12 changes: 12 additions & 0 deletions mise.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
[tools.actionlint]
version = "1.7.4"
backend = "aqua:rhysd/actionlint"

[tools.actionlint.checksums]
"actionlint_1.7.4_darwin_arm64.tar.gz" = "sha256:cbd193bb490f598d77e179261d7b76dfebd049dddede5803ba21cbf6a469aeee"

[tools.cargo-binstall]
version = "1.10.8"
backend = "aqua:cargo-bins/cargo-binstall"

[tools.cargo-binstall.checksums]
"cargo-binstall-aarch64-apple-darwin.zip" = "sha256:23a27d534c98fed95e88c320fd7de154f851af7bce9100eed15e72fee316804c"
Expand All @@ -11,28 +16,35 @@ cargo-binstall-macos-aarch64 = "sha256:c30a499060745f0c4435a446253fc676838cff0a1

[tools."cargo:cargo-edit"]
version = "0.13.0"
backend = "cargo:cargo-edit"

[tools."cargo:cargo-insta"]
version = "1.41.1"
backend = "cargo:cargo-insta"

[tools."cargo:cargo-release"]
version = "0.25.12"
backend = "cargo:cargo-release"

[tools."cargo:git-cliff"]
version = "2.6.1"
backend = "cargo:git-cliff"

[tools.gh]
version = "2.60.1"
backend = "aqua:cli/cli"

[tools.gh.checksums]
"gh_2.60.1_linux_amd64.tar.gz" = "sha256:dfcd9926de38a797e88e604c3111ecf9ddf13c524706712b2b0d2e2fc4a6ed7f"
"gh_2.60.1_macOS_arm64.zip" = "sha256:1930a3db9a2d1c420e476d06f3d4a8f02db8472d2630a1099968c3b82f231f1f"

[tools."npm:prettier"]
version = "3.3.3"
backend = "npm:prettier"

[tools.shellcheck]
version = "0.10.0"
backend = "aqua:koalaman/shellcheck"

[tools.shellcheck.checksums]
shellcheck-macos-aarch64 = "sha256:b9e420df8c78ec7d261d66277d5767cbd4cf6da4e4a9f8b02ea4811cd4cc1109"

0 comments on commit 9e76a17

Please sign in to comment.