Skip to content

Commit

Permalink
Merge pull request #5278 from henry-hsieh/fix-nosort
Browse files Browse the repository at this point in the history
Skip nosort option below bash 4.4
  • Loading branch information
epage authored Jan 2, 2024
2 parents 777b744 + 2b48858 commit adbe6ec
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 12 deletions.
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

0 comments on commit adbe6ec

Please sign in to comment.