#include "esh_misc.h" void EShOptimiseCurrentWorkingDirectory() { if (strstr(esh_info_global->current_working_dir, esh_info_global->user_data->pw_dir) == esh_info_global->current_working_dir) { char new_cwd[PATH_MAX + 1]; memset(new_cwd, 0, PATH_MAX + 1); strcat(new_cwd, "~"); strcat(new_cwd, esh_info_global->current_working_dir + strlen(esh_info_global->user_data->pw_dir)); strcpy(esh_info_global->current_working_dir, new_cwd); } } void EShUpdateInviteMessage() { memset(esh_info_global->invite_message, 0, (esh_info_global->max_invite_message_len + 1) * sizeof(char)); strcat(esh_info_global->invite_message, ANSI_COLOR_BLUE); strcat(esh_info_global->invite_message, esh_info_global->user_data->pw_name); strcat(esh_info_global->invite_message, ANSI_COLOR_RESET); strcat(esh_info_global->invite_message, "@"); strcat(esh_info_global->invite_message, ANSI_COLOR_GREEN); strcat(esh_info_global->invite_message, esh_info_global->current_working_dir); strcat(esh_info_global->invite_message, ANSI_COLOR_RESET); strcat(esh_info_global->invite_message, " ยป "); } void EShShowHelpAndExit() { printf(ANSI_COLOR_RED "ESh (Endevir Shell) build %.8s\n" ANSI_COLOR_RESET "\n" "Usage: esh [-h] [-config FILENAME] [-history FILENAME] [-history_limit INT] [-max_active_jobs INT]\n" "\n" "Description:\n" "This is a simple shell, written in C\n" "\n" "Parameters:\n" "-h shows this message and exits\n" "-config FILENAME uses file with name FILENAME as config file (default: ~/.esh_conf)\n" "-history_path FILENAME uses file with name FILENAME as storage for entered commands history (default: ~/.esh_history)\n" "-history_limit INT limits commands number to keep up to INT (default: 5000 lines)\n" "-max_active_jobs INT limits shell active jobs number up to INT (default: 64)\n" "\n" "\n" "Copyleft. Written by Ivan Arkhipov aka Endevir (me@endevir.ru), MIPT, Dolgoprudny, Russia, 2019.\n", esh_info_global->build_ref); exit(0); }