[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 7/9] builtins/source: add the -l|--library options
From: |
Matheus Afonso Martins Moreira |
Subject: |
[PATCH 7/9] builtins/source: add the -l|--library options |
Date: |
Sun, 5 May 2024 06:55:00 -0300 |
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 <matheus@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
- [PATCH 3/9] findcmd: define the user library finder function, (continued)
[PATCH 5/9] builtins/source: refactor file searching function, Matheus Afonso Martins Moreira, 2024/05/05
[PATCH 6/9] builtins/source: define library search function, Matheus Afonso Martins Moreira, 2024/05/05
[PATCH 7/9] builtins/source: add the -l|--library options,
Matheus Afonso Martins Moreira <=
[PATCH 8/9] builtins/source: search libraries in library mode, Matheus Afonso Martins Moreira, 2024/05/05
[PATCH 9/9] variables: define default BASH_LIBRARIES_PATH, Matheus Afonso Martins Moreira, 2024/05/05
Re: [PATCH 0/9] Add library mode to source builtin, Lawrence Velázquez, 2024/05/05