diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2f68d3b880e7dbd392966039587da933668f5fe6 Binary files /dev/null and b/.DS_Store differ diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 8daa6748db839f7fcbb6d916e04fc0d6c33667a3..1711d56cdcd6d5e4acd7b553beaf4a34bde28bff 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -11,10 +11,10 @@ "_UNICODE" ], "windowsSdkVersion": "10.0.22621.0", - "compilerPath": "C:/msys64/ucrt64/bin/g++.exe", + "compilerPath": "/usr/bin/g++", "cStandard": "c17", "cppStandard": "c++17", - "intelliSenseMode": "windows-msvc-x64" + "intelliSenseMode": "macos-gcc-x64" } ], "version": 4 diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000000000000000000000000000000000..05054c5cd812079b58e2374f06a334dd79d53898 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: g++ build active file", + "command": "/usr/bin/g++", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/nosh.dSYM/Contents/Info.plist b/nosh.dSYM/Contents/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..d0e968f02e8a92b637cc2b9dac250c23b049bed8 --- /dev/null +++ b/nosh.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + <dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleIdentifier</key> + <string>com.apple.xcode.dsym.nosh</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>dSYM</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1</string> + </dict> +</plist> diff --git a/nosh.dSYM/Contents/Resources/DWARF/nosh b/nosh.dSYM/Contents/Resources/DWARF/nosh new file mode 100644 index 0000000000000000000000000000000000000000..3fc7c22b67c20433c7e3f5767bcf47706a45e866 Binary files /dev/null and b/nosh.dSYM/Contents/Resources/DWARF/nosh differ diff --git a/noshx b/noshx new file mode 100755 index 0000000000000000000000000000000000000000..21a5161326705d9e02788794498fed11fefcd2d2 Binary files /dev/null and b/noshx differ diff --git a/nosh.cpp b/noshx.cpp similarity index 86% rename from nosh.cpp rename to noshx.cpp index 7d2d6b48b341a57e8e91d629b26db1b6a8066182..ef3aaa496233641e33e3e71cfa3821ad20fd03e6 100644 --- a/nosh.cpp +++ b/noshx.cpp @@ -16,12 +16,13 @@ * * ------------------------------------------------------------------------------------------------------------------- * - * Noémi Shell (nosh). An open-source Shell developed for Windows-based systems + * Noémi Shell X (noshx). An open-source Shell developed for Unix like systems * * Handles shell operations, heavily inspired by bash and zsh. * * @author Zsombor Szabó-Antalovszky * @author ChatGPT (a lot of help) + * @file noshx.cpp * * Licensed under a modified MIT License. See the license on the Noémi Shell GitLab repo for details. * @@ -29,32 +30,31 @@ * * CHANGELOG * - * Noémi Shell ver. 0.3.3 + * Noémi Shell X ver. 0.1 * - * This version introduces the new 'now' command that prints out the current date and time. - * + * THos version is the first version of the Noémi Shell for UNIX like systems + * */ #include <iostream> #include <string> // Handling strings -#include <vector> -#include <windows.h> // For using the Windows API +#include <vector> +#include <unistd.h> // Standard library for unix like systems #include <filesystem> // For file system operations #include <fstream> // Reading/Creating files #include <cstring> // String operations #include <regex> // For grasp filtering #include <cstdlib> -#include <deque> -const char VERSION[] = "0.3.3"; ///< Change version number here for the entire code + +const char VERSION[] = "0.1"; ///< Change version number here for the entire code #define STRLEN 100 ///< Max string length #define WIDTH 10 ///< Width between columns -char vault[STRLEN]; ///< Storing custom info +char vault[STRLEN]; ///< Storing custom info -namespace fs = std::filesystem; using namespace std; @@ -62,33 +62,37 @@ using namespace std; void handle_pwd(const vector<string>& args); bool is_builtin_command(const vector<string>& args); void handle_noemi(const vector<string>& args); -void handle_list(const vector<string>& args); -void handle_cd(const vector<string>& args); void handle_storage(const vector<string>& args); -void handle_read(const vector<string>& args, string filename); -void handle_grasp(const vector<string>& args); -void handle_tap(const vector<string>& args); -void handle_crush(const vector<string>& args); -void handle_mkdir(const vector<string>& args); -void handle_rn(const vector<string>& args); -void handle_exec(const vector<string>& args); -void handle_help(const vector<string>& args); void handle_now(const vector<string>& args); +// To be implemented commands: + +//void handle_list(const vector<string>& args); +//void handle_cd(const vector<string>& args); +//void handle_read(const vector<string>& args, string filename); +//void handle_grasp(const vector<string>& args); +//void handle_tap(const vector<string>& args); +//void handle_crush(const vector<string>& args); +//void handle_mkdir(const vector<string>& args); +//void handle_rn(const vector<string>& args); +//void handle_exec(const vector<string>& args); +//void handle_help(const vector<string>& args); + + /** * The main function */ int main() { - cout << "Noemi Shell (nosh) ver. " << VERSION << "\n" + cout << "Noémi Shell X (noshx) ver. " << VERSION << "\n" << "Copyright (C) 2025 Zsombor Szabo-Antalovszky\n\n" - << "Type 'help' or '? for list of available commands\n\n"; + << "Type 'help' or '?' for list of available commands\n\n"; string command; // Storing command while (true) { - cout << "nosh> "; + cout << "noshx> "; getline(cin, command); // On 'exit' command @@ -217,11 +221,13 @@ void handle_pwd(const vector<string>& args){ return; // Exit early } - char buffer[MAX_PATH]; // Buffer for path + char buffer[PATH_MAX]; // Buffer for path // Gets the current directory - if (GetCurrentDirectoryA(MAX_PATH, buffer)) { + if (getcwd(buffer, sizeof(buffer)) != NULL){ cout << buffer << endl; + } else { + cerr << ("pwd: error: could not get current working directory"); } } @@ -258,9 +264,9 @@ bool is_builtin_command(const vector<string>& args){ } } - cout << "\nNoemi Shell (nosh) ver. " << VERSION << "\n" + cout << "\nNoémi Shell X (noshx) ver. " << VERSION << "\n" << "Copyright (C) 2025 Zsombor Szabo-Antalovszky\n\n" - << "Type 'help' or '? for list of available commands\n\n"; + << "Type 'help' or '?' for list of available commands\n\n"; return true; } @@ -271,7 +277,7 @@ bool is_builtin_command(const vector<string>& args){ return true; } - system("cls"); + system("clear"); return true; } @@ -281,7 +287,7 @@ bool is_builtin_command(const vector<string>& args){ return true; } - system("cls"); + system("clear"); return true; } @@ -302,17 +308,17 @@ bool is_builtin_command(const vector<string>& args){ } if (args[0] == "cd"){ - handle_cd(args); + //handle_cd(args); return true; } if (args[0] == "exec"){ - handle_exec(args); + //handle_exec(args); return true; } if (args[0] == "list") { - handle_list(args); + //handle_list(args); return true; } @@ -322,32 +328,32 @@ bool is_builtin_command(const vector<string>& args){ } if (args[0] == "read") { - handle_read(args, args[1]); + //handle_read(args, args[1]); return true; } if (args[0] == "grasp"){ - handle_grasp(args); + //handle_grasp(args); return true; } if (args[0] == "tap"){ - handle_tap(args); + //handle_tap(args); return true; } if (args[0] == "crush"){ - handle_crush(args); + //handle_crush(args); return true; } if (args[0] == "mkdir"){ - handle_mkdir(args); + //handle_mkdir(args); return true; } if (args[0] == "rn"){ - handle_rn(args); + //handle_rn(args); return true; } @@ -374,14 +380,14 @@ void handle_noemi(const vector<string>& args){ return; // Exit early } - int time = 60; // Default time 60; + float time = 0.9; // Default time 60; // In case an argument follows the command if (args.size() == 2){ const string option = args[1]; // Set the option variable to the first argument if (option == "-l"){ - time = 500; // 500 milliseconds between each line + time = 1; // 500 milliseconds between each line } else{ cout << "noemi: unrecognized argument " << args[1] << "\n"; @@ -390,33 +396,33 @@ void handle_noemi(const vector<string>& args){ } cout << " \n\t ######### ########\n"; - Sleep(time); + sleep(time); cout << " ############ ###########\n"; - Sleep(time); + sleep(time); cout << " ############### ###############\n"; - Sleep(time); + sleep(time); cout << " #################################\n"; - Sleep(time); + sleep(time); cout << " ###################################\n"; - Sleep(time); + sleep(time); cout << " ###################################\n"; - Sleep(time); + sleep(time); cout << " #################################\n"; - Sleep(time); + sleep(time); cout << " ###############################\n"; - Sleep(time); + sleep(time); cout << " ###########################\n"; - Sleep(time); + sleep(time); cout << " #######################\n"; - Sleep(time); + sleep(time); cout << " ###################\n"; - Sleep(time); + sleep(time); cout << " ###############\n"; - Sleep(time); + sleep(time); cout << " #######\n"; - Sleep(time); + sleep(time); cout << " ###\n"; - Sleep(time); + sleep(time); cout << " #\n\n"; } @@ -425,6 +431,8 @@ void handle_noemi(const vector<string>& args){ * * @param args for arguments. */ + +/* void handle_list(const vector<string>& args){ fs::path target_path = fs::current_path(); @@ -449,13 +457,15 @@ void handle_list(const vector<string>& args){ // If there is an error reading directory cerr << "list: Error reading directory: " << e.what() << endl; } -} +}*/ /** * Handling the 'cd' command for changing directories * * @param args for arguments. */ + +/* void handle_cd(const vector<string>& args) { if (args.size() > 2) { cout << "cd: too many arguments\n"; @@ -493,12 +503,15 @@ void handle_cd(const vector<string>& args) { } +*/ /** * Handling the 'read' command for reading text from text based files. * * @param args for arguments. */ + +/* void handle_read(const vector<string>& args, string filename) { // If there is no argument after command if (args.size() != 2) { @@ -527,7 +540,7 @@ void handle_read(const vector<string>& args, string filename) { file.close(); // CLosing the file } - +*/ /** * Handling the 'store' command for storing a string of maximum 100 characters during runtime. * @@ -560,6 +573,8 @@ void handle_storage(const vector<string>& args) { * * @param args for arguments. */ + +/* void handle_grasp(const vector<string>& args){ if (args.size() != 4){ cout << "Usage: grasp <type> <directory> <pattern>\n"; @@ -624,12 +639,15 @@ void handle_grasp(const vector<string>& args){ } } +*/ /** * Handling the 'tap' command for creating files. * * @param args for arguments. */ + +/* void handle_tap(const vector<string>& args){ if (args.size() != 2){ cout << "Usage: tap <filename>\n"; @@ -647,12 +665,14 @@ void handle_tap(const vector<string>& args){ file.close(); } +*/ /** * Handling the 'crush' command for removing files and directories. * * @param args for arguments. */ +/* void handle_crush(const vector<string>& args) { if (args.size() != 3){ @@ -704,12 +724,15 @@ void handle_crush(const vector<string>& args) { } } +*/ /** * Handling the 'mkdir' command for creating directories. * * @param args for arguments. */ + +/* void handle_mkdir(const vector<string>& args) { if (args.size() != 2){ cout << "Usage: mkdir <directory_name>\n"; @@ -728,12 +751,15 @@ void handle_mkdir(const vector<string>& args) { cout << "Failed to create directory: " << dirName << endl; } } +*/ /** * Handling the 'rn' command for renaming files and directories. * * @param args for arguments. */ + +/* void handle_rn(const vector<string>& args){ if (args.size() != 3){ cout << "Usage: rn <filename> <rename>\n"; @@ -751,4 +777,4 @@ void handle_rn(const vector<string>& args){ { cerr << "Error: " << e.what() << '\n'; } -} \ No newline at end of file +} */ \ No newline at end of file diff --git a/noshx.dSYM/Contents/Info.plist b/noshx.dSYM/Contents/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..80428e3fc910e9016cef2372e9b3bbc34065c1b5 --- /dev/null +++ b/noshx.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + <dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleIdentifier</key> + <string>com.apple.xcode.dsym.noshx</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>dSYM</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1</string> + </dict> +</plist> diff --git a/noshx.dSYM/Contents/Resources/DWARF/noshx b/noshx.dSYM/Contents/Resources/DWARF/noshx new file mode 100644 index 0000000000000000000000000000000000000000..f3e2047fdf988f86891bdd3f942648c0540ed93f Binary files /dev/null and b/noshx.dSYM/Contents/Resources/DWARF/noshx differ