mirror of
https://github.com/envmodules/modules.git
synced 2026-06-10 00:56:30 +08:00
Paginate stderr output into paging command, using 'less' by default, following the same fashion and behavior than 'git' command. Pager is enabled by default in modulecmd script. New global variables 'g_use_pager', 'g_pager' and 'g_pager_opts' control default behavior of module command. Pager is enabled only if stderr stream is attached to a terminal. Pager setup can then be superseeded by environment variables. If LESS variable is set and paging command is set to 'less', default pager options are cleared to use those defined in LESS variable. If MODULES_PAGER variable is defined, its value superseeds paging activation, command and options. If this variable is empty, paging is disabled. If PAGER variable is defined and MODULES_PAGER is unset, PAGER value superseeds paging activation, command and options. If this variable is empty, paging is disabled. Default behavior and MODULES_PAGER or PAGER environment variables can be superseeded by command-line options: --paginate to enable paging and --no-pager to disable it. When pager is enabled, a pipe file descripted is ignited to the paging command and option for stderr stream. Once set, this file descriptor is used by all report procedures to output message content, rather using stderr. modulecmd command-line parse has been revised not to output message during argument treatment. Debug, warning and error messages are saved to then be displayed once pager setup is achieved. An 'initPager' procedure is introduced to configure then start paging. A 'cleanupAndExit' is added to close pager before exiting if pager has been started.