Aptivi - Deprecated Manuals
ProjectsWebsiteBlog
Nitrocid KS v0.1.0 Beta 2 - Manual
Nitrocid KS v0.1.0 Beta 2 - Manual
  • 👋Welcome!
  • Versions and Compatibility
    • 🔱Supported Versions
    • 🕘EOL Versions
    • 🗞️Version Release Notes
      • ✨v0.0.1.x series
      • 🌈v0.0.2.x series
      • 👥v0.0.3.x series
      • 🛠️v0.0.4.x series
      • 🕔v0.0.5.x series
        • ⌚v0.0.5.0 Beta Versions
      • 📕v0.0.6.x series
        • 📄v0.0.6.0 Beta Versions
      • 🔌v0.0.7.x series
        • ⚡v0.0.7.0 Beta Versions
      • 🌌v0.0.8.x series
      • 💌v0.0.9.x series
      • 📜v0.0.10.x series
      • ✏️v0.0.11.x series
      • ⚙️v0.0.12.x series
      • 🌐v0.0.13.x series
      • 🏃♀ v0.0.14.x series
      • ⏳v0.0.15.x series
      • ⭐v0.0.16.x series
      • 🌃v0.0.17.x series
      • 🥁v0.0.18.x series
      • 🔧v0.0.19.x series
      • 🍀v0.0.20.x series
      • 🧰v0.0.21.x series
      • 📱v0.0.22.x series
      • 🖥️v0.0.23.x series
      • 👾v0.0.24.x series
      • 🔮v0.1.x.x series
        • ⚠️Known issues for 0.1.0 Beta
    • 👍Compatibility Notes for KS API Revisions
      • 🔼Upgrading from API v1.0
      • 🔼Upgrading from API v1.1
      • 🔼Upgrading from API v1.2
      • 🔼Upgrading from API v1.3
      • 🔼Upgrading from API v2.0
      • 🔼Upgrading from API v2.1
      • 🔼Upgrading to API v3.0
  • Installation and Maintenance
    • 📀Installing the Kernel
      • 💻Windows
      • 🐧Linux
      • 📱Android
    • ⏫Upgrading the Kernel
      • 💻Windows
      • 🐧Linux
      • 📱Android
  • Fundamentals
    • 🌽What is the Kernel?
    • 👾What is Nitrocid KS?
    • 🌟Simulated Kernel Features
      • 👤Accounts
        • 🔓Permissions
      • 🐚Shells
      • 🌍Networking
        • 🗃️FTP Client
        • 🔒SFTP Client
        • 📰RSS Client
        • 🌐HTTP Client
        • 📧Mail Client
      • ✏️Editors
        • 📝Text Editor
        • 🖊️JSON Editor
        • 💾Hex Editor
      • 🇺🇸 Languages
      • 🌌Screensavers
      • 🎮Games and Amusements
        • 🔤Hangman
        • ☄️Meteor
        • 🐍Snaker
        • 🔢Solver
        • ⌨️SpeedPress
        • 🔠Wordle
      • 🗓️Calendar
      • ⏰Stopwatch and Timer
      • ⚖️Calculator and Converter
  • Advanced and Power Users
    • ⚒️Building the Kernel
      • 🪟Building on Windows
      • 🐧Building on Linux
    • 🧰Kernel Modifications
      • 🔧Kernel Modification Management
      • 🏗️Build your...
        • 🧪Your Mod
        • 🌌Your Screensaver
        • 🪄Your Splash
    • 🦠Diagnostics
      • 🔬Debugging
        • 🧬Local Debugging
        • 🛰️Remote Debugging
      • 🧪Testing
      • 💉Other Diagnostics
    • ⚒️Inner Workings
      • 🔧Kernel Settings
        • ⛏️Mechanics of Settings App
        • 🔩Settings Format
      • 🐚Shell Structure
        • ❔Help System
        • 🗜️Command Parsing
        • 📜Shell Scripting
      • 🪧Kernel Placeholders
      • 🔐The Permissions
      • 📞Kernel Threads
      • 🔌Kernel Drivers
      • ⚙️Multilingual Kernel Flow
      • 🌐Custom Languages
      • 📽️Presentation System
      • 🎛️Kernel Arguments
      • 📡Remote Procedure
    • 💿GRILO Bootloader and KS
  • 🧱Project Dependencies
  • Report an issue
  • Source code
  • API Reference
Powered by GitBook
On this page
Edit on GitHub
  1. Advanced and Power Users
  2. Inner Workings
  3. Shell Structure

Command Parsing

How command parsing works

Once the GetLine() function got your input, it attempts to split any command with the semicolon between them, like:

command1 arg1 arg2 ; command2 arg3 arg4

Any command that starts with either a space or a hashtag will be ignored as a comment, like:

 comment
#comment

The first word is a command, and all words following it in a single command text are the series of arguments. These words then get split to arguments (without the switch indicator -switch) and switches (arguments that come after the dash) using the ProvidedCommandArgumentsInfo class, though it does much more than that.

This class contains these variables:

  • Command: Target command

  • ArgumentsText: Provided arguments and switches

  • ArgumentsList: Array of arguments without the switches

  • SwitchesList: Array of switches

  • RequiredArgumentsProvided: Checks to see if the arguments are provided or not

After the above class constructor is called, the shell attempts to execute a mod or alias command, if found. Else, the built-in command is going to be executed. It checks for these redirection flags:

  • >>: Redirects the output to a file, overwriting the target file

  • >>>: Redirects the output to a file, appending to the target file

  • |SILENT|: Redirects the output to a null console driver, which means no output

If these flags are found, the shell sets the console driver as appropriate.

The shell then checks to see if the command is executable with the current user permissions. If the command is a strict command (CommandFlags.Strict) and the user has been granted either the administrator status or the PermissionTypes.RunStrictCommands permission, or if the command is not a strict command, then the shell is able to execute the specified command.

However, if the maintenance mode is on and the command is set not to run on maintenance mode (CommandFlags.NoMaintenance), then the shell bails from executing the command, with the message that it can't run in maintenance mode.

Finally, the command executor thread is fired up with the ExecuteCommandParameters instance to hold command execution parameters for the same thread. The thread is then started.

However, the command executor checks for these:

  • If the provided command is a UESH script, the shell invokes a script executor.

  • If the command is an external program found in the shell lookup path, which is usually $PATH, the shell attempts to scan these directories for the program and execute it.

  • If the command is an internal command, it creates a separate thread for the command.

Switch Management

There is a static class dedicated to managing the switches, called SwitchManager. It allows you to manage the switches with the values. There are two functions that specialize in getting the switch values: GetSwitchValues and GetSwitchValue.

The first function returns the list of switches with their values stored in a tuple, and the second function returns the switch value for a specified switch or a blank value if not found.

You can always use these functions with the SwitchesOnly array found in the Execute() function in the CommandBase class.

Last updated 1 year ago

⚒️
🐚
🗜️