[PATCH 3/4] findcmd: define the user import finder function
From:
Matheus Afonso Martins Moreira
Subject:
[PATCH 3/4] findcmd: define the user import finder function
Date:
Thu, 2 May 2024 19:22:32 -0300
The find_user_import function looks for executable scripts
in a separate location meant for reusable libraries and modules,
separate from other executables.
Signed-off-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
---
findcmd.c | 12 ++++++++++++
findcmd.h | 1 +
2 files changed, 13 insertions(+)
diff --git a/findcmd.c b/findcmd.c
index cef342e0..6ad62c73 100644
--- a/findcmd.c
+++ b/findcmd.c
@@ -244,6 +244,18 @@ find_user_command (name)
return (find_user_command_internal (name, "PATH",
FS_EXEC_PREFERRED|FS_NODIRS));
}
+/* Locate the executable file referenced by NAME, searching along
+ the contents of the shell BASH_IMPORT_PATH variable.
+ Return a new string which is the full pathname to the file,
+ or NULL if the file couldn't be found.
+ Only executables can be found. */
+char *
+find_user_import (name)
+ const char *name;
+{
+ return (find_user_command_internal (name, "BASH_IMPORT_PATH",
FS_EXEC_ONLY|FS_NODIRS));
+}
+
/* Locate the file referenced by NAME, searching along the contents
of the shell PATH variable. Return a new string which is the full
pathname to the file, or NULL if the file couldn't be found. This
diff --git a/findcmd.h b/findcmd.h
index bf457814..16c8bc8b 100644
--- a/findcmd.h
+++ b/findcmd.h
@@ -33,6 +33,7 @@ extern int executable_file PARAMS((const char *));
extern int is_directory PARAMS((const char *));
extern int executable_or_directory PARAMS((const char *));
extern char *find_user_command PARAMS((const char *));
+extern char *find_user_import PARAMS((const char *));
extern char *find_in_path PARAMS((const char *, char *, int));
extern char *find_path_file PARAMS((const char *));
extern char *search_for_command PARAMS((const char *, int));
--
2.44.0