diff --git a/Makefile b/Makefile index 49bdce61..8c000889 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: ldulling +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/12/23 03:22:46 by ldulling #+# #+# # -# Updated: 2024/07/31 02:14:58 by ldulling ### ########.fr # +# Updated: 2024/08/24 00:02:23 by ldulling ### ########.fr # # # # **************************************************************************** # @@ -16,6 +16,7 @@ # Executable NAME := minishell +MAKE_NAME := Crash # Directories @@ -94,14 +95,14 @@ ABSOLUTE_PATHS := /bin/* \ # Terminal -TERMINAL := $(shell which gnome-terminal 2> /dev/null) +TERMINAL := $(shell which gnome-terminal 2>/dev/null) ifeq ($(filter val,$(MAKECMDGOALS)),val) -TERMINALTITLE := valgrind $(NAME) +TERMINALTITLE := valgrind $(MAKE_NAME) else ifeq ($(filter valfd,$(MAKECMDGOALS)),valfd) -TERMINALTITLE := valgrind-fd $(NAME) +TERMINALTITLE := valgrind-fd $(MAKE_NAME) else -TERMINALTITLE := $(NAME) +TERMINALTITLE := $(MAKE_NAME) endif TERMINALFLAGS := --title="$(TERMINALTITLE)" -- /bin/sh -c @@ -120,132 +121,133 @@ OBJ_SUBDIRS := $(sort $(dir $(OBJ))) DEP_SUBDIRS := $(sort $(dir $(DEP))) -# ***************************** BUILD PROCESS ******************************** # +# *************************** BUILD PREPARATION ****************************** # + +export CC CFLAGS MAKECMDGOALS MAKEFLAGS -PHONY_TARGETS := all fast run san val noenv valfd help build lib waitforlib \ - clean fclean ffclean re -HELP_TARGETS := help \ - $(addprefix help-,$(PHONY_TARGETS)) \ - $(addsuffix -help,$(PHONY_TARGETS)) +PHONY_TARGETS := all run noenv nocolor opt san val valfd term clear modes re \ + build lib waitforlib clean fclean ffclean +ENV_VARIABLES := MODE +HELP_TARGETS := help help-print \ + $(addprefix help-,$(PHONY_TARGETS) $(ENV_VARIABLES)) \ + $(addsuffix -help,$(PHONY_TARGETS) $(ENV_VARIABLES)) PHONY_TARGETS += $(HELP_TARGETS) +export .PHONY : $(PHONY_TARGETS) -.PHONY : $(PHONY_TARGETS) +REBUILD_TARGETS := nocolor opt san re +CLEAN_TARGETS := clean fclean ffclean .DEFAULT : $(MAKE) help +.DEFAULT_GOAL := all -# Compilation - -all : - if $(MAKE) --question build; then \ - echo $(MSG_NO_CHNG); \ - echo $(MSG_HELP); \ - else \ - echo " "$(MSG_INFO); \ - echo " "$(MSG_HELP); \ - echo -n $(MSG_START); \ - if $(MAKE) build; then \ - echo; \ - echo $(MSG_SUCCESS); \ - else \ - echo; \ - echo $(MSG_FAILURE); \ - exit 42; \ - fi; \ - fi - -help-all : - echo "Build the project." - echo "This is the default target when no target is specified." +# ********************************* MODES ************************************ # -fast : CFLAGS := $(CFLAGS_STD) $(CFLAGS_OPT) -fast : re - $(MAKE) clean - -help-fast : - echo "Build the project with the following compiler optimization flags:" - echo " $(CFLAGS_OPT)" - +ifeq (run,$(filter run,$(MAKECMDGOALS) $(MODE))) +RUN := true +endif -run : all - "./$(NAME)" +ifeq (noenv,$(filter noenv,$(MAKECMDGOALS) $(MODE))) +ENV := env -i +RUN := true +endif -help-run : - echo "Build the project and run the executable." +ifeq (nocolor,$(filter nocolor,$(MAKECMDGOALS) $(MODE))) +MACROS += -D NO_COLOR=1 +RECOMPILE := true +endif +ifeq (opt,$(filter opt,$(MAKECMDGOALS) $(MODE))) +CFLAGS := $(CFLAGS_STD) $(CFLAGS_OPT) +RECOMPILE := true +endif -san : CFLAGS := $(CFLAGS_STD) $(CFLAGS_DBG) $(CFLAGS_SAN) -san : re - $(MAKE) clean - "./$(NAME)" +ifeq (san,$(filter san,$(MAKECMDGOALS) $(MODE))) +CFLAGS += $(CFLAGS_STD) $(CFLAGS_DBG) $(CFLAGS_SAN) +RECOMPILE := true +endif -help-san : - echo "Rebuild the project with sanitizers enabled and run the executable." - echo "The following sanitizers are enabled:" - echo " $(CFLAGS_SAN)" +ifeq (val,$(filter val,$(MAKECMDGOALS) $(MODE))) +ENV += $(VALGRIND) $(VALGRINDFLAGS) +PATH := /bin:/usr/bin:/usr/sbin:$(PATH) +RUN := true +endif +ifeq (valfd,$(filter valfd,$(MAKECMDGOALS) $(MODE))) +ENV += $(VALGRIND) $(VALGRINDFLAGS) $(VALGRINDFDFLAGS) +PATH := /bin:/usr/bin:/usr/sbin:$(PATH) +NEW_TERM := true +RUN := true +endif -val : all - $(VALGRIND) $(VALGRINDFLAGS) "./$(NAME)" +ifeq (term,$(filter term,$(MAKECMDGOALS) $(MODE))) +NEW_TERM := true +RUN := true +endif -help-val : - echo "Build the project and run the executable with valgrind." - echo "The following valgrind flags are used:" - echo "$(VALGRINDFLAGS)" | tr ' ' '\n' | sed 's/^/ /' +ifeq (clear,$(filter clear,$(MAKECMDGOALS) $(MODE))) +CLEAR := true +endif -noenv : all - env -i $(VALGRIND) $(VALGRINDFLAGS) "./$(NAME)" +# ***************************** BUILD TARGETS ******************************** # -help-noenv : - echo "Build and run the project with valgrind and with empty environment (env -i)." +all : + if $(MAKE) --question build; then \ + echo -n $(MSG_NO_CHANGE); \ + echo -n $(MSG_HELP); \ + else \ + echo -n $(MSG_MODE); \ + echo -n " "$(MSG_INFO); \ + echo -n " "$(MSG_HELP); \ + echo -n $(MSG_START); \ + if $(MAKE) build; then \ + echo; \ + echo -n $(MSG_SUCCESS); \ + else \ + echo; \ + echo -n $(MSG_FAILURE); \ + exit 42; \ + fi; \ + fi +run noenv nocolor opt san val valfd term clear: modes -valfd : all -ifneq ($(TERMINAL),) - $(TERMINAL) $(TERMINALFLAGS) \ - "bash --posix -c 'trap \"\" SIGINT ; \ - $(VALGRIND) $(VALGRINDFLAGS) $(VALGRINDFDFLAGS) ./$(NAME) ; \ - exec bash --posix'" -else - $(VALGRIND) $(VALGRINDFLAGS) $(VALGRINDFDFLAGS) "./$(NAME)" -endif +modes : + if [ "$(RECOMPILE)" = "true" ]; then \ + MAKELEVEL=$$(( $(MAKELEVEL) - 1 )) MSG_SUCCESS="" $(MAKE) re; \ + MAKELEVEL=$$(( $(MAKELEVEL) - 1 )) $(MAKE) clean; \ + else \ + MAKELEVEL=$$(( $(MAKELEVEL) - 1 )) $(MAKE) all; \ + fi + if [ "$(CLEAR)" = "true" ]; then \ + clear; \ + fi + if [ "$(NEW_TERM)" = "true" ] && [ -n "$(TERMINAL)" ]; then \ + $(TERMINAL) $(TERMINALFLAGS) \ + "bash --posix -c 'trap \"\" SIGINT; \ + $(ENV) ./$(NAME); \ + exec bash --posix'"; \ + elif [ "$(RUN)" = "true" ]; then \ + $(ENV) "./$(NAME)"; \ + fi -help-valfd : - echo "Build and run the project with valgrind and file descriptor tracking." - echo "The following valgrind flags are used:" - echo "$(VALGRINDFLAGS)" | tr ' ' '\n' | sed 's/^/ /' - echo "File descriptor specific flags:" - echo "$(VALGRINDFDFLAGS)" | tr ' ' '\n' | sed 's/^/ /' +re : + $(MAKE) fclean + MAKELEVEL=$$(( $(MAKELEVEL) - 1 )) $(MAKE) all -help : - echo "Usage: make [target]" - echo - echo "Targets:" - echo " all - Build the project (default target)" - echo " fast - Build the project with optimizations" - echo " run - Build and run the project" - echo " san - Build and run the project with sanitizers" - echo " val - Build and run the project with valgrind" - echo " noenv - Build and run the project with valgrind and with empty environment" - echo " valfd - Build and run the project with valgrind and file descriptor tracking" - echo " clean - Remove build artifacts" - echo " fclean - Remove build artifacts and executable" - echo " ffclean - Remove build artifacts and executable without checking for unknown files" - echo " re - Rebuild the project" - echo " print-% - Print the value of a Makefile variable (replace % with variable name)" - echo " help - Display this message" - echo " help-% - Display more information for a specific target (replace % with target name)" - echo " %-help - Display more information for a specific target (replace % with target name)" +# ***************************** BUILD PROCESS ******************************** # -help-help : - echo "Display more information for a specific target by appending or prepending help." +# Dependency files inclusion -%-help: - $(MAKE) help-$(subst -help,,$@) +ifeq (,$(filter $(HELP_TARGETS) $(REBUILD_TARGETS) $(CLEAN_TARGETS),$(MAKECMDGOALS))) + ifneq (,$(wildcard $(OBJ_DIR))) + -include $(DEP) + endif +endif # Library dependency management @@ -260,21 +262,19 @@ endif # Library compilation -export CC CFLAGS MAKECMDGOALS MAKEFLAGS - lib : $(MAKE) -C $(LIBRARIES) waitforlib : lib -# Executable linking +# Executable linkage $(NAME) : $(LIBRARIES) $(OBJ) $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) $(LDLIBS) -o $(NAME) -# Source file compiling +# Source file compilation $(OBJ_DIR)/%.o : $(SRC_DIR)/%.c $(BUILDFILES) | $(OBJ_SUBDIRS) $(CC) $(CFLAGS) $(MACROS) $(INCFLAGS) -c $< -o $@ \ @@ -284,66 +284,147 @@ $(OBJ_DIR)/%.o : $(SRC_DIR)/%.c $(BUILDFILES) | $(OBJ_SUBDIRS) # Pre-processing and dependency file creation $(DEP_DIR)/%.d : $(SRC_DIR)/%.c $(BUILDFILES) | $(DEP_SUBDIRS) - $(CC) $(CFLAGS) $(MACROS) $(INCFLAGS) \ - -M -MP -MF $@ -MT "$(OBJ_DIR)/$*.o $@" $< + $(CC) $(CFLAGS) $(MACROS) $(INCFLAGS) -M -MP -MF $@ -MT "$(OBJ_DIR)/$*.o $@" $< -# Mirror directory structure of source files for build artifacts +# Directory structure mirroring of source files for build artifacts $(OBJ_SUBDIRS) \ $(DEP_SUBDIRS) : mkdir -p $@ -# Cleaning +# ***************************** CLEAN TARGETS ******************************** # clean : + echo -n $(MSG_CLEAN) $(MAKE) clean -C $(LIBRARIES) rm -f $(OBJ) $(DEP) -ifneq (,$(wildcard $(OBJ_DIR))) - -find $(OBJ_DIR) -type d -empty -delete -endif -ifneq (,$(wildcard $(DEP_DIR))) - -find $(DEP_DIR) -type d -empty -delete -endif + ifneq (,$(wildcard $(OBJ_DIR))) + -find $(OBJ_DIR) -type d -empty -delete + endif + ifneq (,$(wildcard $(DEP_DIR))) + -find $(DEP_DIR) -type d -empty -delete + endif + echo -n $(MSG_SUCCESS) + +fclean : + echo -n $(MSG_FCLEAN) + $(MAKE) clean + $(MAKE) fclean -C $(LIBRARIES) + rm -f $(NAME) + echo -n $(MSG_SUCCESS) -help-clean : - echo "Remove build artifacts." +ffclean : + echo -n $(MSG_FFCLEAN) + $(MAKE) fclean + rm -rf $(OBJ_DIR) $(DEP_DIR) + echo -n $(MSG_SUCCESS) -fclean : clean - $(MAKE) fclean -C $(LIBRARIES) - rm -f $(NAME) +# ****************************** HELP TARGETS ******************************** # -help-fclean : - echo "Remove build artifacts and the executable." +help : + echo "Usage: make [\\$(STY_UND)target\\$(STY_RES)] [MODE=\"<\\$(STY_UND)mode1\\$(STY_RES)> [\\$(STY_UND)mode2\\$(STY_RES)] [...]\"]" + echo + echo "Targets:" + echo " all Build the project (default target)" + echo " run Build and run the project" + echo " noenv Build and run the project with an empty environment" + echo " nocolor Rebuild the project without colors in the prompt and printouts" + echo " opt Rebuild the project with optimizations" + echo " san Rebuild the project with sanitizers" + echo " val Build and run the project with valgrind" + echo " valfd Build and run the project with valgrind and file descriptor tracking" + echo " term Build and run the project in a new terminal window" + echo " clear Build the project and clear the terminal" + echo " re Rebuild the project" + echo " clean Remove build artifacts" + echo " fclean Remove build artifacts and executable" + echo " ffclean Remove build artifacts and executable without checking for unknown files" + echo " print-% Print the value of a Makefile variable (replace % with variable name)" + echo " help Display this message" + echo " help-% | %-help Display more information for a specific target (replace % with target name)" + echo + echo "Environment Variables:" + echo " MODE Build mode to combine multiple targets" + echo +help-all : + echo "Build the project." + echo "This is the default target when no target is specified." -ffclean : fclean - rm -rf $(OBJ_DIR) $(DEP_DIR) +help-run : + echo "Build the project and run the executable." -help-ffclean : - echo "Remove build artifacts and the executable without checking for unknown files." +help-noenv : + echo "Build the project and run executable with an empty environment (env -i)." +help-nocolor : + echo "Rebuild the project without colors in the prompt and printouts." + echo "Avoids issues when moving the cursor in the input line." -re : - $(MAKE) fclean - $(MAKE) all +help-opt : + echo "Rebuild the project with the following compiler optimization flags:" + echo " $(CFLAGS_OPT)" + +help-san : + echo "Rebuild the project with the following sanitizer flags:" + echo " $(CFLAGS_SAN)" + +help-val : + echo "Build the project and run the executable with valgrind." + echo "The following valgrind flags are used:" + echo "$(VALGRINDFLAGS)" | tr ' ' '\n' | sed 's/^/ /' + +help-valfd : + echo "Build the project and run the executable with valgrind and file descriptor tracking." + echo "A new terminal window is opened to avoid inheriting open file descriptors." + echo "The following valgrind flags are used:" + echo "$(VALGRINDFLAGS)" | tr ' ' '\n' | sed 's/^/ /' + echo "File descriptor specific flags:" + echo "$(VALGRINDFDFLAGS)" | tr ' ' '\n' | sed 's/^/ /' + +help-term : + echo "Build the project and run the executable in a new terminal window." + +help-clear : + echo "Build the project and clear the terminal." help-re : echo "Rebuild the project." +help-clean : + echo "Remove build artifacts." -# Include dependency files +help-fclean : + echo "Remove build artifacts and the executable." -ifeq (,$(filter $(HELP_TARGETS) clean fclean ffclean re,$(MAKECMDGOALS))) - ifneq (,$(wildcard $(OBJ_DIR))) - -include $(DEP) - endif -endif +help-ffclean : + echo "Remove build artifacts and the executable without checking for unknown files." + +help-print : + echo "Usage: make print-<\\$(STY_UND)variable name\\$(STY_RES)>" + echo + echo "Print the value of a Makefile variable by appending the variable name to print-..." + echo "Useful for Makefile debugging." + +help-help : + echo "Usage: make help-<\\$(STY_UND)target\\$(STY_RES)> | make <\\$(STY_UND)target\\$(STY_RES)>-help" + echo + echo "Display more information for a specific target by appending or prepending help." + +help-MODE MODE-help: + echo "Usage: make <\\$(STY_UND)target\\$(STY_RES)> MODE=\"<\\$(STY_UND)mode1\\$(STY_RES)> [\\$(STY_UND)mode2\\$(STY_RES)] [...]\"" + echo + echo "Build mode to combine with other targets." + echo "Multiple modes can be combined by separating them with a space." + +%-help: + $(MAKE) help-$(subst -help,,$@) -# **************************** COLORS ******************************* # +# ********************************* COLORS *********************************** # STY_RES := "\e[0m" STY_BOL := "\e[1m" @@ -358,7 +439,7 @@ STY_CYA := "\e[36m" STY_WHI := "\e[37m" STY_GRA := "\e[90m" STY_WHI_BRI := "\e[97m" -STY_BLA_BG := "\e[41m" +STY_BLA_BG := "\e[40m" STY_RED_BG := "\e[41m" STY_GRE_BG := "\e[42m" STY_YEL_BG := "\e[43m" @@ -372,28 +453,94 @@ STY_WHI_BRI_BG := "\e[107m" # **************************** CUSTOM MESSAGES ******************************* # -################################################################################ -MSG_INFO := $(STY_ITA)$(STY_WHI)"Make version: $(MAKE_VERSION)\n\ - Compiler version: $(CC_VERSION)"$(STY_RES) -################################################################################ -MSG_HELP := $(STY_ITA)$(STY_WHI)"Run 'make help' to see all available Makefile targets."$(STY_RES) -################################################################################ -MSG_START := $(STY_ITA)"Building Crash ... "$(STY_RES) -################################################################################ MSG_PROGRESS := $(STY_ITA)"🌊"$(STY_RES) -################################################################################ -MSG_SUCCESS := $(STY_BOL)$(STY_ITA)$(STY_CYA)"DONE!"$(STY_RES) -################################################################################ -MSG_NO_CHNG := $(STY_ITA)$(STY_WHI)"Everything up-to-date!"$(STY_RES) -################################################################################ -MSG_FAILURE := $(STY_BOL)$(STY_ITA)$(STY_RED)"BUILD FAILED!"$(STY_RES) + + +########################## Top-level only messages ############################# +ifeq ($(MAKELEVEL),0) + +# Make status messages + +MSG_INFO := $(STY_ITA)$(STY_WHI)"Make version: $(MAKE_VERSION)\n\ + Compiler version: $(CC_VERSION)"$(STY_RES)"\n" + +MSG_HELP := $(STY_ITA)$(STY_WHI)"Run 'make help' to see all available Makefile targets."$(STY_RES)"\n" + +ifneq (,$(filter $(REBUILD_TARGETS),$(MAKECMDGOALS) $(MODE))) +MSG_START := $(STY_ITA)"Rebuilding $(MAKE_NAME) ... "$(STY_RES) +else +MSG_START := $(STY_ITA)"Building $(MAKE_NAME) ... "$(STY_RES) +endif + +MSG_SUCCESS ?= $(STY_BOL)$(STY_ITA)$(STY_CYA)"DONE!"$(STY_RES)"\n" + +MSG_NO_CHANGE := $(STY_ITA)$(STY_WHI)"Everything up-to-date!"$(STY_RES)"\n" + +MSG_FAILURE := $(STY_BOL)$(STY_ITA)$(STY_RED)"BUILD FAILED!"$(STY_RES)"\n" + + +# Build modes + +MSG_RUN := $(STY_BOL)$(STY_ITA)$(STY_UND)$(STY_YEL)"~~~~~~~~~~~~~~~~~~~~~~~ RUN MODE ~~~~~~~~~~~~~~~~~~~~~~~"$(STY_RES)"\n" +ifneq (,$(filter run,$(MAKECMDGOALS) $(MODE))) +MSG_MODE := $(MSG_MODE)$(MSG_RUN) +endif + +MSG_NOENV := $(STY_BOL)$(STY_ITA)$(STY_UND)$(STY_MAG)"~~~~~~~~~~~~~~~~ EMPTY ENVIRONMENT MODE ~~~~~~~~~~~~~~~~"$(STY_RES)"\n" +ifneq (,$(filter noenv,$(MAKECMDGOALS) $(MODE))) +MSG_MODE := $(MSG_MODE)$(MSG_NOENV) +endif + +MSG_NOCOLOR := $(STY_BOL)$(STY_ITA)$(STY_UND)$(STY_WHI_BRI)"~~~~~~~~~~~~~~~~~~~~~ NO COLOR MODE ~~~~~~~~~~~~~~~~~~~~"$(STY_RES)"\n" +ifneq (,$(filter nocolor,$(MAKECMDGOALS) $(MODE))) +MSG_MODE := $(MSG_MODE)$(MSG_NOCOLOR) +endif + +MSG_OPT := $(STY_BOL)$(STY_ITA)$(STY_UND)$(STY_GRE)"~~~~~~~~~~~~~~~~~~~ OPTIMIZATION MODE ~~~~~~~~~~~~~~~~~~"$(STY_RES)"\n" +ifneq (,$(filter opt,$(MAKECMDGOALS) $(MODE))) +MSG_MODE := $(MSG_MODE)$(MSG_OPT) +endif + +MSG_SAN := $(STY_BOL)$(STY_ITA)$(STY_UND)$(STY_RED)"~~~~~~~~~~~~~~~~~~~~ SANITIZER MODE ~~~~~~~~~~~~~~~~~~~~"$(STY_RES)"\n" +ifneq (,$(filter san,$(MAKECMDGOALS) $(MODE))) +MSG_MODE := $(MSG_MODE)$(MSG_SAN) +endif + +MSG_VAL := $(STY_BOL)$(STY_ITA)$(STY_UND)$(STY_BLU)"~~~~~~~~~~~~~~~~~~~~~ VALGRIND MODE ~~~~~~~~~~~~~~~~~~~~"$(STY_RES)"\n" +ifneq (,$(filter val,$(MAKECMDGOALS) $(MODE))) +MSG_MODE := $(MSG_MODE)$(MSG_VAL) +endif + +MSG_VALFD := $(STY_BOL)$(STY_ITA)$(STY_UND)$(STY_CYA)"~~~~~~~~~~~~~~~~~~~ VALGRIND FD MODE ~~~~~~~~~~~~~~~~~~~"$(STY_RES)"\n" +ifneq (,$(filter valfd,$(MAKECMDGOALS) $(MODE))) +MSG_MODE := $(MSG_MODE)$(MSG_VALFD) +endif + +MSG_TERM := $(STY_BOL)$(STY_ITA)$(STY_UND)$(STY_YEL)"~~~~~~~~~~~~~~~~~~~ NEW TERMINAL MODE ~~~~~~~~~~~~~~~~~~"$(STY_RES)"\n" +ifneq (,$(filter term,$(MAKECMDGOALS) $(MODE))) +MSG_MODE := $(MSG_MODE)$(MSG_TERM) +endif + +MSG_CLEAR := $(STY_BOL)$(STY_ITA)$(STY_UND)$(STY_GRA)"~~~~~~~~~~~~~~~~~~~~~ CLEAR MODE ~~~~~~~~~~~~~~~~~~~~"$(STY_RES)"\n" +ifneq (,$(filter clear,$(MAKECMDGOALS) $(MODE))) +MSG_MODE := $(MSG_MODE)$(MSG_CLEAR) +endif + + +# Clean messages + +MSG_CLEAN := $(STY_ITA)"Cleaning up build artifacts ... "$(STY_RES)"\n" + +MSG_FCLEAN := $(STY_ITA)"Cleaning up build artifacts and executable ... "$(STY_RES)"\n" + +MSG_FFCLEAN := $(STY_ITA)"Forcefully cleaning up build artifacts directory and executable ... "$(STY_RES)"\n" + +endif ################################################################################ # *************************** MAKEFILE DEBUGGING ***************************** # -# Execute "make print-[variable name]" to list the variable's values - print-% : echo $* = $($*) diff --git a/include/defines.h b/include/defines.h index 0decd71a..195f6575 100644 --- a/include/defines.h +++ b/include/defines.h @@ -52,10 +52,20 @@ # endif # define PROGRAM_NAME "crash" -# define PRETTY_PROG_NAME "\e[3;34m🌊\e[0m\e[1;34mrash\e[0m" -# define PROMPT "\e[3;34m🌊\e[0m\e[1;34mrash$\e[0m " +# if NO_COLOR +# define PRETTY_PROG_NAME "🌊rash" +# define PROMPT "🌊rash$ " +# else +# define PRETTY_PROG_NAME "\e[3;34m🌊\e[0m\e[1;34mrash\e[0m" +# define PROMPT "\e[3;34m🌊\e[0m\e[1;34mrash$\e[0m " +# endif + +# if NO_COLOR +# define HEREDOC_PROMPT "> " +# else +# define HEREDOC_PROMPT "\e[1;37m> \e[0m" +# endif -# define HEREDOC_PROMPT "\e[1;37m> \e[0m" # define EXIT_MSG "exit\n" # define WELCOME_MSG "\ @@ -63,8 +73,13 @@ β”‚ Dive deep into the shell β”‚\n\ β•°β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€πŸŒŠπŸŒŠπŸŒŠβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β•―\n" -# define VALERIA_MSG "\ +# if NO_COLOR +# define VALERIA_MSG "\ + Big thank you to @ValeriaGart for the pixel art!\n" +# else +# define VALERIA_MSG "\ Big thank you to \e[1m@ValeriaGart\e[0m for the pixel art!\n" +# endif /* Error Codes */ # define SUCCESS 0 @@ -81,29 +96,55 @@ # define FORK_ERROR 254 /* Text-Style Escape Codes */ -# define STY_RES "\e[0m" -# define STY_BOL "\e[1m" -# define STY_ITA "\e[3m" -# define STY_UND "\e[4m" -# define STY_RED "\e[31m" -# define STY_GRE "\e[32m" -# define STY_YEL "\e[33m" -# define STY_BLU "\e[34m" -# define STY_MAG "\e[35m" -# define STY_CYA "\e[36m" -# define STY_WHI "\e[37m" -# define STY_GRA "\e[90m" -# define STY_WHI_BRI "\e[97m" -# define STY_BLA_BG "\e[41m" -# define STY_RED_BG "\e[41m" -# define STY_GRE_BG "\e[42m" -# define STY_YEL_BG "\e[43m" -# define STY_BLU_BG "\e[44m" -# define STY_MAG_BG "\e[45m" -# define STY_CYA_BG "\e[46m" -# define STY_WHI_BG "\e[47m" -# define STY_GRA_BG "\e[100m" -# define STY_WHI_BRI_BG "\e[107m" +# if NO_COLOR +# define STY_RES "" +# define STY_BOL "" +# define STY_ITA "" +# define STY_UND "" +# define STY_RED "" +# define STY_GRE "" +# define STY_YEL "" +# define STY_BLU "" +# define STY_MAG "" +# define STY_CYA "" +# define STY_WHI "" +# define STY_GRA "" +# define STY_WHI_BRI "" +# define STY_BLA_BG "" +# define STY_RED_BG "" +# define STY_GRE_BG "" +# define STY_YEL_BG "" +# define STY_BLU_BG "" +# define STY_MAG_BG "" +# define STY_CYA_BG "" +# define STY_WHI_BG "" +# define STY_GRA_BG "" +# define STY_WHI_BRI_BG "" +# else +# define STY_RES "\e[0m" +# define STY_BOL "\e[1m" +# define STY_ITA "\e[3m" +# define STY_UND "\e[4m" +# define STY_RED "\e[31m" +# define STY_GRE "\e[32m" +# define STY_YEL "\e[33m" +# define STY_BLU "\e[34m" +# define STY_MAG "\e[35m" +# define STY_CYA "\e[36m" +# define STY_WHI "\e[37m" +# define STY_GRA "\e[90m" +# define STY_WHI_BRI "\e[97m" +# define STY_BLA_BG "\e[41m" +# define STY_RED_BG "\e[41m" +# define STY_GRE_BG "\e[42m" +# define STY_YEL_BG "\e[43m" +# define STY_BLU_BG "\e[44m" +# define STY_MAG_BG "\e[45m" +# define STY_CYA_BG "\e[46m" +# define STY_WHI_BG "\e[47m" +# define STY_GRA_BG "\e[100m" +# define STY_WHI_BRI_BG "\e[107m" +# endif /* Symbols */ # define WORD_SEPERATORS " \t\n"