Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip nosort option below bash 4.4 #5278

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion clap_complete/src/shells/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ impl Generator for Bash {
esac
}}

complete -F _{name} -o nosort -o bashdefault -o default {name}
if [[ \"${{BASH_VERSINFO[0]}}\" -eq 4 && \"${{BASH_VERSINFO[1]}}\" -ge 4 || \"${{BASH_VERSINFO[0]}}\" -gt 4 ]]; then
complete -F _{name} -o nosort -o bashdefault -o default {name}
else
complete -F _{name} -o bashdefault -o default {name}
fi
",
name = bin_name,
cmd = bin_name.replace('-', "__"),
Expand Down
6 changes: 5 additions & 1 deletion clap_complete/tests/snapshots/aliases.bash
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ _my-app() {
esac
}

complete -F _my-app -o nosort -o bashdefault -o default my-app
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _my-app -o nosort -o bashdefault -o default my-app
else
complete -F _my-app -o bashdefault -o default my-app
fi
6 changes: 5 additions & 1 deletion clap_complete/tests/snapshots/basic.bash
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,8 @@ _my-app() {
esac
}

complete -F _my-app -o nosort -o bashdefault -o default my-app
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _my-app -o nosort -o bashdefault -o default my-app
else
complete -F _my-app -o bashdefault -o default my-app
fi
6 changes: 5 additions & 1 deletion clap_complete/tests/snapshots/feature_sample.bash
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,8 @@ _my-app() {
esac
}

complete -F _my-app -o nosort -o bashdefault -o default my-app
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _my-app -o nosort -o bashdefault -o default my-app
else
complete -F _my-app -o bashdefault -o default my-app
fi
Original file line number Diff line number Diff line change
Expand Up @@ -1002,5 +1002,9 @@ _exhaustive() {
esac
}

complete -F _exhaustive -o nosort -o bashdefault -o default exhaustive
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _exhaustive -o nosort -o bashdefault -o default exhaustive
else
complete -F _exhaustive -o bashdefault -o default exhaustive
fi

6 changes: 5 additions & 1 deletion clap_complete/tests/snapshots/quoting.bash
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,8 @@ _my-app() {
esac
}

complete -F _my-app -o nosort -o bashdefault -o default my-app
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _my-app -o nosort -o bashdefault -o default my-app
else
complete -F _my-app -o bashdefault -o default my-app
fi
6 changes: 5 additions & 1 deletion clap_complete/tests/snapshots/special_commands.bash
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,8 @@ _my-app() {
esac
}

complete -F _my-app -o nosort -o bashdefault -o default my-app
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _my-app -o nosort -o bashdefault -o default my-app
else
complete -F _my-app -o bashdefault -o default my-app
fi
6 changes: 5 additions & 1 deletion clap_complete/tests/snapshots/sub_subcommands.bash
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,8 @@ _my-app() {
esac
}

complete -F _my-app -o nosort -o bashdefault -o default my-app
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _my-app -o nosort -o bashdefault -o default my-app
else
complete -F _my-app -o bashdefault -o default my-app
fi
6 changes: 5 additions & 1 deletion clap_complete/tests/snapshots/subcommand_last.bash
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,8 @@ _my-app() {
esac
}

complete -F _my-app -o nosort -o bashdefault -o default my-app
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _my-app -o nosort -o bashdefault -o default my-app
else
complete -F _my-app -o bashdefault -o default my-app
fi
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ _my-app() {
esac
}

complete -F _my-app -o nosort -o bashdefault -o default my-app
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _my-app -o nosort -o bashdefault -o default my-app
else
complete -F _my-app -o bashdefault -o default my-app
fi
6 changes: 5 additions & 1 deletion clap_complete/tests/snapshots/value_hint.bash
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,8 @@ _my-app() {
esac
}

complete -F _my-app -o nosort -o bashdefault -o default my-app
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _my-app -o nosort -o bashdefault -o default my-app
else
complete -F _my-app -o bashdefault -o default my-app
fi
6 changes: 5 additions & 1 deletion clap_complete/tests/snapshots/value_terminator.bash
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ _my-app() {
esac
}

complete -F _my-app -o nosort -o bashdefault -o default my-app
if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
complete -F _my-app -o nosort -o bashdefault -o default my-app
else
complete -F _my-app -o bashdefault -o default my-app
fi
Loading