Shell Structure
Explaining the inner workings of all the kernel shells
Kernel shells can be built by implementing two different interfaces and base classes. Why two? Because the shell handler relies on:
BaseShellandIShell: To hold shell type and initialization codeBaseShellInfo<ShellType>andIShellInfo: To hold shell commands and the base shell
To learn more about general information about shells, consult the page below:
ShellsWhat is a shell?If you want to know about Nitrocid-specific additions, read on.
Return codes
The kernel exceptions can be used as return codes, though you'll have to reference to a class, called KernelExceptionTools, to be able to get an error code by exception type using the GetErrorCode() function. In addition to that, you can also use it with an instance of a kernel exception instance, in case you've wrapped the code with the try...catch clause and that you're catching all the KernelException errors, which almost all APIs throw on either a failure condition or an invalid operation.
Here's a minimal example of what exit does when you're trying to exit the mother shell:
public override int Execute(CommandParameters parameters, ref string variableValue)
{
if (ShellManager.IsOnMotherShell())
{
TextWriters.Write(Translate.DoTranslation("You can't exit the mother shell. Did you mean to log out of your account, shut the kernel down, or reboot it?"), KernelColorType.Error);
return KernelExceptionTools.GetErrorCode(KernelExceptionType.ShellOperation);
}
ShellManager.KillShell();
return 0;
}Error codes
The error code variable, MESHErrorCode, holds information about the last process error code, whether it's a success (a zero value) or a failure (non-zero value). In addition to what Terminaux already provides, these values are supported:
Error codes that come from the commands
10000 + KernelExceptionTypeSome commands throw this value from any
KernelExceptionthat is thrown by the command executor. Indicates that the command failed to perform its operation, but the kernel already knows about it.Example: If
KernelExceptionType.Configis thrown from the command executor, and the command knows how to return this exception as an error code, such as usingKernelExceptionTools.GetErrorCode(), then it'll return the sum of10000 + 7, which is10007.
Command-specific error codes
1Indicates that the command answered n to the confirmation (FTP and SFTP's
delcommand)
2Indicates that either the real or the imaginary number is not valid (
imaginarycommand)
3Indicates that the unit type is not found (
unitconvcommand)
4Indicates that the hashes don't match (
verifycommand)
5Indicates that the version code can't be formed (
versioncommand)Indicates that the action taken is invalid (
todocommand)
6Indicates that the version code can't be formed (
platformcommand)
7Indicates that the line endings converter can't convert binary files (
convertlineendingscommand)
8Indicates that the note number is not numeric (
removenotecommand)
9Indicates that the repository has been modified (
checkoutcommand)
10Indicates that the branch doesn't exist (
checkoutcommand)
11Indicates that the repository has been modified (
fetchcommand)
12Indicates that the remote doesn't exist (
fetchcommand)
13Indicates that there are no remotes to pull updates from (
fetchcommand)
14Indicates that you need to identify yourself (
pullcommand)
15Indicates that you need to identify yourself (
maketagandcommitcommand)
16Indicates that the culture is not found (
altdatecommand)
17Indicates that there is no such lyric file (
playlyriccommand)
18Indicates that the number of times is invalid (
repeatcommand)
19Indicates that repeat can't repeat itself (
repeatcommand)
20Indicates that the number of columns is invalid (
wraptextcommand)
21Indicates that the extension handler is not registered (
getdefaultexthandlercommand)
22Indicates that the extension handler is not registered (
getexthandlerscommand)
23Indicates that the extension is not registered (
setexthandlercommand)
24Indicates that the extension implementer is not registered (
setexthandlercommand)
25Indicates that the port number is invalid (
netfminfocommand)
26Indicates that the number of seconds or the drink name is invalid (
caffeinecommand)
27Indicates that there is no such lyric file (
lyriclinescommand)
28Indicates that there is no config or key (
getconfigvalue,setconfigvalue, andlsconfigvaluescommand)
29Indicates that the music file is not found (
playsoundcommand)
30Indicates that the MPG123 library has timed out (
playsoundcommand)Indicates that the music file is not specified (
musicplayercommand)
31Indicates that the music file is not found (
musicplayercommand)
32Indicates that there are no caffeine alerts to abort (
caffeinecommand)
33Indicates that this command is not supported on Windows (
showmainbuffercommand)
34Indicates that the dock is not found (
dockcommand)
Last updated