Skip to content

Commit

Permalink
Throw internal error on calling dummy built-in (re: c5018f7)
Browse files Browse the repository at this point in the history
It's best for the temporary parse-time dummy built-in not to simply
call b_true() but to actually give an "internal error" message, as
it is never supposed to be called.
  • Loading branch information
McDutchie committed Jan 25, 2024
1 parent d5e45f4 commit 9f11f24
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cmd/ksh93/bltins/typeset.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ int b_typeset(int argc,char *argv[],Shbltin_t *context)
new_argv[1] = "-n";
else
{
errormsg(SH_DICT, ERROR_exit(128), "internal error");
errormsg(SH_DICT, ERROR_PANIC, e_internal);
UNREACHABLE();
}
for (n = 1; n <= argc; n++)
Expand Down
1 change: 1 addition & 0 deletions src/cmd/ksh93/data/msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const char e_badrange[] = "%d-%d: invalid range";
const char e_eneedsarg[] = "-e - requires single argument";
const char e_limit[] = "%s: could not get limit";
const char e_overlimit[] = "%s: limit exceeded";
const char e_internal[] = "internal error";
const char e_badsyntax[] = "incorrect syntax";
const char e_badwrite[] = "write to %d failed";
const char e_staticfun[] = "%s: defined as a static function in type %s and cannot be redefined";
Expand Down
1 change: 1 addition & 0 deletions src/cmd/ksh93/include/builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ extern const char e_notimp[];
extern const char e_nosupport[];
extern const char e_limit[];
extern const char e_overlimit[];
extern const char e_internal[];

extern const char e_eneedsarg[];
extern const char e_oneoperand[];
Expand Down
11 changes: 10 additions & 1 deletion src/cmd/ksh93/sh/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ static void typeset_order(const char *str,int line)
}
}

static int b_dummy(int argc, char *argv[], Shbltin_t *context)
{
NOT_USED(argc);
NOT_USED(argv[0]);
NOT_USED(context);
errormsg(SH_DICT,ERROR_PANIC,e_internal);
UNREACHABLE();
}

/*
* This function handles linting for 'typeset' options via typeset_order().
*
Expand Down Expand Up @@ -233,7 +242,7 @@ static void check_typedef(struct comnod *tp, char intypeset)
dcl_tree = dtopen(&_Nvdisc, Dtoset);
dtview(sh.bltin_tree, dcl_tree);
}
nv_onattr(sh_addbuiltin(cp, b_true, NULL), NV_BLTIN|BLT_DCL);
nv_onattr(sh_addbuiltin(cp, b_dummy, NULL), NV_BLTIN|BLT_DCL);
}
}
/*
Expand Down

0 comments on commit 9f11f24

Please sign in to comment.