diff --git a/include/zephyr/shell/shell.h b/include/zephyr/shell/shell.h index 91dd73a2d9b..a19418fa528 100644 --- a/include/zephyr/shell/shell.h +++ b/include/zephyr/shell/shell.h @@ -1008,9 +1008,10 @@ int shell_stop(const struct shell *sh); * @param[in] fmt Format string. * @param[in] ... List of parameters to print. */ -void __printf_like(3, 4) shell_fprintf(const struct shell *sh, - enum shell_vt100_color color, - const char *fmt, ...); +void __printf_like(3, 4) shell_fprintf_impl(const struct shell *sh, enum shell_vt100_color color, + const char *fmt, ...); + +#define shell_fprintf(sh, color, fmt, ...) shell_fprintf_impl(sh, color, fmt, ##__VA_ARGS__) /** * @brief vprintf-like function which sends formatted data stream to the shell. @@ -1277,4 +1278,9 @@ int shell_get_return_value(const struct shell *sh); } #endif +#ifdef CONFIG_SHELL_CUSTOM_HEADER +/* This include must always be at the end of shell.h */ +#include +#endif + #endif /* SHELL_H__ */ diff --git a/subsys/shell/Kconfig b/subsys/shell/Kconfig index 5921a56bb49..c9907839959 100644 --- a/subsys/shell/Kconfig +++ b/subsys/shell/Kconfig @@ -297,6 +297,14 @@ config SHELL_CMDS_RETURN_VALUE This option enables the retval command. It is used to retrieve the return value from the most recently executed command. +config SHELL_CUSTOM_HEADER + bool "Include Custom Shell Header" + help + When enabled, a custom application provided header, named + "zephyr_custom_shell.h", is included at the end of shell.h. This enables + extension of the shell APIs at the macro level. Please use cautiously! + The internal shell API may change in future releases. + source "subsys/shell/modules/Kconfig" endif # SHELL diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index 1bd8de70d02..29f9d856d5f 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -1548,7 +1548,7 @@ void shell_vfprintf(const struct shell *sh, enum shell_vt100_color color, /* This function mustn't be used from shell context to avoid deadlock. * However it can be used in shell command handlers. */ -void shell_fprintf(const struct shell *sh, enum shell_vt100_color color, +void shell_fprintf_impl(const struct shell *sh, enum shell_vt100_color color, const char *fmt, ...) { va_list args;