#endif
/* Embedded script support */
-//int find_script_by_name(const char *arg IF_FEATURE_SH_STANDALONE(, int offset)) FAST_FUNC;
+int find_script_by_name(const char *name) FAST_FUNC;
char *get_script_content(unsigned n) FAST_FUNC;
/* Applets which are useful from another applets */
# endif /* NUM_APPLETS > 0 */
# if NUM_SCRIPTS > 0
-static int
-find_script_by_name(const char *arg)
+int FAST_FUNC
+find_script_by_name(const char *name)
{
const char *s = script_names;
int i = 0;
while (*s) {
- if (strcmp(arg, s) == 0)
+ if (strcmp(name, s) == 0)
return i;
i++;
while (*s++ != '\0')
continue;
}
- return -1;
+ return -0x10000; /* make it so that NUM_APPLETS + <error> is still < 0 */
}
static char *
if (strchr(prog, '/') != NULL
#if ENABLE_FEATURE_SH_STANDALONE
|| (applet_no = find_applet_by_name(prog)) >= 0
+# if NUM_SCRIPTS > 0
+ || (applet_no = NUM_APPLETS + find_script_by_name(prog)) >= 0
+# endif
#endif
) {
tryexec(IF_FEATURE_SH_STANDALONE(applet_no,) prog, argv, envp);
*/
/* find_command() encodes applet_no as (-2 - applet_no) */
int applet_no = (- cmdentry.u.index - 2);
+# if NUM_SCRIPTS > 0
+ /* Applets are ok, but not embedded scripts */
+ if (applet_no < NUM_APPLETS)
+# endif
if (applet_no >= 0 && APPLET_IS_NOFORK(applet_no)) {
char **sv_environ;
#if ENABLE_FEATURE_SH_STANDALONE
{
int applet_no = find_applet_by_name(name);
+# if NUM_SCRIPTS > 0
+ if (applet_no < 0)
+ /* embedded script indices are offset by NUM_APPLETS */
+ applet_no = NUM_APPLETS + find_script_by_name(name);
+# endif
if (applet_no >= 0) {
entry->cmdtype = CMDNORMAL;
entry->u.index = -2 - applet_no;