mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
Make ! a builtin too, fixing "! -h"
UnLike other aliases (":.["), ! is special in the grammar but in the few cases like "! -h" where we parse it as decorated statement they are equals. Add it to the built in list, so the help argument works. It can still be overridden, so this should not break anything.
This commit is contained in:
parent
373bb56441
commit
6d18f57e96
@ -1,5 +1,7 @@
|
||||
function __fish_print_help --description "Print help message for the specified fish function or builtin" --argument-names item error_message
|
||||
switch $item
|
||||
case !
|
||||
set item not
|
||||
case .
|
||||
set item source
|
||||
case :
|
||||
|
@ -129,6 +129,8 @@ function help --description 'Show help for the fish shell'
|
||||
|
||||
set -l fish_help_page
|
||||
switch "$fish_help_item"
|
||||
case "!"
|
||||
set fish_help_page "cmds/not.html"
|
||||
case "."
|
||||
set fish_help_page "cmds/source.html"
|
||||
case ":"
|
||||
|
@ -113,6 +113,10 @@ struct BuiltinData {
|
||||
// Functions that are bound to builtin_generic are handled directly by the parser.
|
||||
// NOTE: These must be kept in sorted order!
|
||||
const BUILTIN_DATAS: &[BuiltinData] = &[
|
||||
BuiltinData {
|
||||
name: L!("!"),
|
||||
func: builtin_generic,
|
||||
},
|
||||
BuiltinData {
|
||||
name: L!("."),
|
||||
func: source::source,
|
||||
@ -471,6 +475,7 @@ pub fn builtin_get_names() -> impl Iterator<Item = &'static wstr> {
|
||||
/// Return a one-line description of the specified builtin.
|
||||
pub fn builtin_get_desc(name: &wstr) -> Option<&'static wstr> {
|
||||
let desc = match name {
|
||||
_ if name == "!" => wgettext!("Negate exit status of job"),
|
||||
_ if name == "." => wgettext!("Evaluate contents of file"),
|
||||
_ if name == ":" => wgettext!("Return a successful result"),
|
||||
_ if name == "[" => wgettext!("Test a condition"), // ]
|
||||
|
@ -8,3 +8,14 @@ echo $status
|
||||
not not sh -c 'exit 34'
|
||||
echo $status
|
||||
# CHECK: 34
|
||||
|
||||
! -h
|
||||
# CHECKERR: fish: !: missing man page
|
||||
# CHECKERR: Documentation may not be installed.
|
||||
# CHECKERR: `help !` will show an online version
|
||||
|
||||
function !
|
||||
echo overridden! $argv
|
||||
end
|
||||
! -h
|
||||
# CHECK: overridden! -h
|
||||
|
Loading…
x
Reference in New Issue
Block a user