mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
Make false/true into builtins
Making `true` into a builtin is a significant optimization to `while true` loops. As long as `true` is a builtin, we may as well make `false` builtin as well (despite the fact that it's not typically executed in a loop).
This commit is contained in:
parent
27dd37ebb4
commit
d67800bbce
4 changed files with 44 additions and 8 deletions
12
builtin.cpp
12
builtin.cpp
|
@ -4001,6 +4001,16 @@ int builtin_parse(parser_t &parser, wchar_t **argv)
|
||||||
return STATUS_BUILTIN_OK;
|
return STATUS_BUILTIN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int builtin_true(parser_t &parser, wchar_t **argv)
|
||||||
|
{
|
||||||
|
return STATUS_BUILTIN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int builtin_false(parser_t &parser, wchar_t **argv)
|
||||||
|
{
|
||||||
|
return STATUS_BUILTIN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
END OF BUILTIN COMMANDS
|
END OF BUILTIN COMMANDS
|
||||||
Below are functions for handling the builtin commands.
|
Below are functions for handling the builtin commands.
|
||||||
|
@ -4038,6 +4048,7 @@ static const builtin_data_t builtin_datas[]=
|
||||||
{ L"end", &builtin_generic, N_(L"End a block of commands") },
|
{ L"end", &builtin_generic, N_(L"End a block of commands") },
|
||||||
{ L"exec", &builtin_generic, N_(L"Run command in current process") },
|
{ L"exec", &builtin_generic, N_(L"Run command in current process") },
|
||||||
{ L"exit", &builtin_exit, N_(L"Exit the shell") },
|
{ L"exit", &builtin_exit, N_(L"Exit the shell") },
|
||||||
|
{ L"false", &builtin_false, N_(L"Return an unsuccessful result") },
|
||||||
{ L"fg", &builtin_fg, N_(L"Send job to foreground") },
|
{ L"fg", &builtin_fg, N_(L"Send job to foreground") },
|
||||||
{ L"for", &builtin_generic, N_(L"Perform a set of commands multiple times") },
|
{ L"for", &builtin_generic, N_(L"Perform a set of commands multiple times") },
|
||||||
{ L"function", &builtin_generic, N_(L"Define a new function") },
|
{ L"function", &builtin_generic, N_(L"Define a new function") },
|
||||||
|
@ -4058,6 +4069,7 @@ static const builtin_data_t builtin_datas[]=
|
||||||
{ L"status", &builtin_status, N_(L"Return status information about fish") },
|
{ L"status", &builtin_status, N_(L"Return status information about fish") },
|
||||||
{ L"switch", &builtin_generic, N_(L"Conditionally execute a block of commands") },
|
{ L"switch", &builtin_generic, N_(L"Conditionally execute a block of commands") },
|
||||||
{ L"test", &builtin_test, N_(L"Test a condition") },
|
{ L"test", &builtin_test, N_(L"Test a condition") },
|
||||||
|
{ L"true", &builtin_true, N_(L"Return a successful result") },
|
||||||
{ L"ulimit", &builtin_ulimit, N_(L"Set or get the shells resource usage limits") },
|
{ L"ulimit", &builtin_ulimit, N_(L"Set or get the shells resource usage limits") },
|
||||||
{ L"while", &builtin_generic, N_(L"Perform a command multiple times") }
|
{ L"while", &builtin_generic, N_(L"Perform a command multiple times") }
|
||||||
};
|
};
|
||||||
|
|
10
doc_src/false.txt
Normal file
10
doc_src/false.txt
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
\section false false - return an unsuccessful result
|
||||||
|
|
||||||
|
\subsection false-synopsis Synopsis
|
||||||
|
\fish{synopsis}
|
||||||
|
false
|
||||||
|
\endfish
|
||||||
|
|
||||||
|
\subsection false-description Description
|
||||||
|
|
||||||
|
`false` sets the exit status to 1.
|
10
doc_src/true.txt
Normal file
10
doc_src/true.txt
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
\section true true - return a successful result
|
||||||
|
|
||||||
|
\subsection true-synopsis Synopsis
|
||||||
|
\fish{synopsis}
|
||||||
|
true
|
||||||
|
\endfish
|
||||||
|
|
||||||
|
\subsection true-description Description
|
||||||
|
|
||||||
|
`true` sets the exit status to 0.
|
|
@ -171,8 +171,8 @@
|
||||||
D0F019FD15A977CA0034B3B1 /* config.fish in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0C4FD9415A7D7EE00212EF1 /* config.fish */; };
|
D0F019FD15A977CA0034B3B1 /* config.fish in CopyFiles */ = {isa = PBXBuildFile; fileRef = D0C4FD9415A7D7EE00212EF1 /* config.fish */; };
|
||||||
D0F01A0315A978910034B3B1 /* osx_fish_launcher.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D02AFA159871B2008E62BD /* osx_fish_launcher.m */; };
|
D0F01A0315A978910034B3B1 /* osx_fish_launcher.m in Sources */ = {isa = PBXBuildFile; fileRef = D0D02AFA159871B2008E62BD /* osx_fish_launcher.m */; };
|
||||||
D0F01A0515A978A10034B3B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0CBD583159EEE010024809C /* Foundation.framework */; };
|
D0F01A0515A978A10034B3B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0CBD583159EEE010024809C /* Foundation.framework */; };
|
||||||
D0F5B46519CFCDE80090665E /* wcstringutil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0F5B46319CFCDE80090665E /* wcstringutil.cpp */; };
|
D0F5B46519CFCDE80090665E /* wcstringutil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0F5B46319CFCDE80090665E /* wcstringutil.cpp */; };
|
||||||
D0F5B46619CFCEBC0090665E /* wcstringutil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0F5B46319CFCDE80090665E /* wcstringutil.cpp */; };
|
D0F5B46619CFCEBC0090665E /* wcstringutil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0F5B46319CFCDE80090665E /* wcstringutil.cpp */; };
|
||||||
D0FE8EE8179FB760008C9F21 /* parse_productions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FE8EE7179FB75F008C9F21 /* parse_productions.cpp */; };
|
D0FE8EE8179FB760008C9F21 /* parse_productions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D0FE8EE7179FB75F008C9F21 /* parse_productions.cpp */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
@ -456,8 +456,8 @@
|
||||||
D0D2693C159835CA005D9B9C /* fish */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fish; sourceTree = BUILT_PRODUCTS_DIR; };
|
D0D2693C159835CA005D9B9C /* fish */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fish; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
D0D9B2B318555D92001AE279 /* parse_constants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = parse_constants.h; sourceTree = "<group>"; };
|
D0D9B2B318555D92001AE279 /* parse_constants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = parse_constants.h; sourceTree = "<group>"; };
|
||||||
D0F3373A1506DE3C00ECEFC0 /* builtin_test.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = builtin_test.cpp; sourceTree = "<group>"; };
|
D0F3373A1506DE3C00ECEFC0 /* builtin_test.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = builtin_test.cpp; sourceTree = "<group>"; };
|
||||||
D0F5B46319CFCDE80090665E /* wcstringutil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wcstringutil.cpp; sourceTree = "<group>"; };
|
D0F5B46319CFCDE80090665E /* wcstringutil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wcstringutil.cpp; sourceTree = "<group>"; };
|
||||||
D0F5B46419CFCDE80090665E /* wcstringutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wcstringutil.h; sourceTree = "<group>"; };
|
D0F5B46419CFCDE80090665E /* wcstringutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wcstringutil.h; sourceTree = "<group>"; };
|
||||||
D0F5E28415A7A32D00315DFF /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
|
D0F5E28415A7A32D00315DFF /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
|
||||||
D0FE8EE6179CA8A5008C9F21 /* parse_productions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parse_productions.h; sourceTree = "<group>"; };
|
D0FE8EE6179CA8A5008C9F21 /* parse_productions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parse_productions.h; sourceTree = "<group>"; };
|
||||||
D0FE8EE7179FB75F008C9F21 /* parse_productions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parse_productions.cpp; sourceTree = "<group>"; };
|
D0FE8EE7179FB75F008C9F21 /* parse_productions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parse_productions.cpp; sourceTree = "<group>"; };
|
||||||
|
@ -644,8 +644,8 @@
|
||||||
D0C9733718DE5449002D7C81 /* utf8.cpp */,
|
D0C9733718DE5449002D7C81 /* utf8.cpp */,
|
||||||
D0A0852613B3ACEE0099B651 /* util.h */,
|
D0A0852613B3ACEE0099B651 /* util.h */,
|
||||||
D0A0855E13B3ACEE0099B651 /* util.cpp */,
|
D0A0855E13B3ACEE0099B651 /* util.cpp */,
|
||||||
D0F5B46419CFCDE80090665E /* wcstringutil.h */,
|
D0F5B46419CFCDE80090665E /* wcstringutil.h */,
|
||||||
D0F5B46319CFCDE80090665E /* wcstringutil.cpp */,
|
D0F5B46319CFCDE80090665E /* wcstringutil.cpp */,
|
||||||
D0A0852713B3ACEE0099B651 /* wgetopt.h */,
|
D0A0852713B3ACEE0099B651 /* wgetopt.h */,
|
||||||
D0A0855F13B3ACEE0099B651 /* wgetopt.cpp */,
|
D0A0855F13B3ACEE0099B651 /* wgetopt.cpp */,
|
||||||
D0A0852813B3ACEE0099B651 /* wildcard.h */,
|
D0A0852813B3ACEE0099B651 /* wildcard.h */,
|
||||||
|
@ -926,6 +926,8 @@
|
||||||
"$(SRCROOT)/doc_src/umask.txt",
|
"$(SRCROOT)/doc_src/umask.txt",
|
||||||
"$(SRCROOT)/doc_src/vared.txt",
|
"$(SRCROOT)/doc_src/vared.txt",
|
||||||
"$(SRCROOT)/doc_src/while.txt",
|
"$(SRCROOT)/doc_src/while.txt",
|
||||||
|
"$(SRCROOT)/doc_src/true.txt",
|
||||||
|
"$(SRCROOT)/doc_src/false.txt",
|
||||||
);
|
);
|
||||||
outputPaths = (
|
outputPaths = (
|
||||||
"$(BUILT_PRODUCTS_DIR)/man/man1/alias.1",
|
"$(BUILT_PRODUCTS_DIR)/man/man1/alias.1",
|
||||||
|
@ -998,6 +1000,8 @@
|
||||||
"$(BUILT_PRODUCTS_DIR)/man/man1/umask.1",
|
"$(BUILT_PRODUCTS_DIR)/man/man1/umask.1",
|
||||||
"$(BUILT_PRODUCTS_DIR)/man/man1/vared.1",
|
"$(BUILT_PRODUCTS_DIR)/man/man1/vared.1",
|
||||||
"$(BUILT_PRODUCTS_DIR)/man/man1/while.1",
|
"$(BUILT_PRODUCTS_DIR)/man/man1/while.1",
|
||||||
|
"$(BUILT_PRODUCTS_DIR)/man/man1/true.1",
|
||||||
|
"$(BUILT_PRODUCTS_DIR)/man/man1/false.1",
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
|
@ -1041,7 +1045,7 @@
|
||||||
D007692E1990137800CA4627 /* reader.cpp in Sources */,
|
D007692E1990137800CA4627 /* reader.cpp in Sources */,
|
||||||
D007692F1990137800CA4627 /* sanity.cpp in Sources */,
|
D007692F1990137800CA4627 /* sanity.cpp in Sources */,
|
||||||
D00769301990137800CA4627 /* tokenizer.cpp in Sources */,
|
D00769301990137800CA4627 /* tokenizer.cpp in Sources */,
|
||||||
D0F5B46619CFCEBC0090665E /* wcstringutil.cpp in Sources */,
|
D0F5B46619CFCEBC0090665E /* wcstringutil.cpp in Sources */,
|
||||||
D00769311990137800CA4627 /* wildcard.cpp in Sources */,
|
D00769311990137800CA4627 /* wildcard.cpp in Sources */,
|
||||||
D00769321990137800CA4627 /* wgetopt.cpp in Sources */,
|
D00769321990137800CA4627 /* wgetopt.cpp in Sources */,
|
||||||
D00769331990137800CA4627 /* wutil.cpp in Sources */,
|
D00769331990137800CA4627 /* wutil.cpp in Sources */,
|
||||||
|
@ -1094,7 +1098,7 @@
|
||||||
D0D02A67159837AD008E62BD /* complete.cpp in Sources */,
|
D0D02A67159837AD008E62BD /* complete.cpp in Sources */,
|
||||||
D0D02A69159837B2008E62BD /* env.cpp in Sources */,
|
D0D02A69159837B2008E62BD /* env.cpp in Sources */,
|
||||||
D0D02A6A1598381A008E62BD /* exec.cpp in Sources */,
|
D0D02A6A1598381A008E62BD /* exec.cpp in Sources */,
|
||||||
D0F5B46519CFCDE80090665E /* wcstringutil.cpp in Sources */,
|
D0F5B46519CFCDE80090665E /* wcstringutil.cpp in Sources */,
|
||||||
D0D02A6B1598381F008E62BD /* expand.cpp in Sources */,
|
D0D02A6B1598381F008E62BD /* expand.cpp in Sources */,
|
||||||
D00F63F119137E9D00FCCDEC /* fish_version.cpp in Sources */,
|
D00F63F119137E9D00FCCDEC /* fish_version.cpp in Sources */,
|
||||||
D0D02A6C15983829008E62BD /* highlight.cpp in Sources */,
|
D0D02A6C15983829008E62BD /* highlight.cpp in Sources */,
|
||||||
|
|
Loading…
Reference in a new issue