Passing these options to the source builtin enables library loading mode which restricts its search path to the directories defined by the BASH_LIBRARIES_PATH variable.
Signed-off-by: Matheus Afonso Martins Moreira <math...@matheusmoreira.com> --- builtins/source.def | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/builtins/source.def b/builtins/source.def index 0809c19d..8ca9631f 100644 --- a/builtins/source.def +++ b/builtins/source.def @@ -131,9 +131,28 @@ source_builtin (list) WORD_LIST *list; { char *filename, *x; + int opt, library_mode = 0; - if (no_options (list)) - return (EX_USAGE); + struct option_conversion conversions[] = { + { "--library", 'l' }, + { NULL, '\0' }, + }; + + shorten_long_options (list, conversions); + reset_internal_getopt (); + while ((opt = internal_getopt (list, "l")) != -1) + { + switch (opt) + { + case 'l': + library_mode = 1; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } list = loptend; if (list == 0) -- 2.44.0