summaryrefslogtreecommitdiff
path: root/builtins/evalfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtins/evalfile.c')
-rw-r--r--builtins/evalfile.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/builtins/evalfile.c b/builtins/evalfile.c
index 1116b093..f3342215 100644
--- a/builtins/evalfile.c
+++ b/builtins/evalfile.c
@@ -57,8 +57,9 @@ extern int errno;
#define FEVAL_LONGJMP 0x010
#define FEVAL_HISTORY 0x020
#define FEVAL_CHECKBINARY 0x040
+#define FEVAL_REGFILE 0x080
-extern int interactive, interactive_shell, posixly_correct;
+extern int posixly_correct;
extern int indirection_level, startup_state, subshell_environment;
extern int return_catch_flag, return_catch_value;
extern int last_command_exit_value;
@@ -68,7 +69,7 @@ int sourcelevel = 0;
static int
_evalfile (filename, flags)
- char *filename;
+ const char *filename;
int flags;
{
volatile int old_interactive;
@@ -77,7 +78,9 @@ _evalfile (filename, flags)
char *string;
struct stat finfo;
size_t file_size;
- VFunction *errfunc;
+ sh_vmsg_func_t *errfunc;
+
+ USE_VAR(pflags);
fd = open (filename, O_RDONLY);
@@ -97,14 +100,14 @@ file_error_and_exit:
: ((errno == ENOENT) ? 0 : -1));
}
- errfunc = (VFunction *)((flags & FEVAL_BUILTIN) ? builtin_error : internal_error);
+ errfunc = ((flags & FEVAL_BUILTIN) ? builtin_error : internal_error);
if (S_ISDIR (finfo.st_mode))
{
(*errfunc) ("%s: is a directory", filename);
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
}
- else if (S_ISREG (finfo.st_mode) == 0)
+ else if ((flags & FEVAL_REGFILE) && S_ISREG (finfo.st_mode) == 0)
{
(*errfunc) ("%s: not a regular file", filename);
return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1);
@@ -122,7 +125,7 @@ file_error_and_exit:
setmode (fd, O_TEXT);
#endif
- string = xmalloc (1 + file_size);
+ string = (char *)xmalloc (1 + file_size);
result = read (fd, string, file_size);
string[result] = '\0';
@@ -143,7 +146,7 @@ file_error_and_exit:
}
if ((flags & FEVAL_CHECKBINARY) &&
- check_binary_file ((unsigned char *)string, (result > 80) ? 80 : result))
+ check_binary_file (string, (result > 80) ? 80 : result))
{
free (string);
(*errfunc) ("%s: cannot execute binary file", filename);
@@ -207,7 +210,7 @@ file_error_and_exit:
int
maybe_execute_file (fname, force_noninteractive)
- char *fname;
+ const char *fname;
int force_noninteractive;
{
char *filename;
@@ -225,20 +228,20 @@ maybe_execute_file (fname, force_noninteractive)
#if defined (HISTORY)
int
fc_execute_file (filename)
- char *filename;
+ const char *filename;
{
int flags;
/* We want these commands to show up in the history list if
remember_on_history is set. */
- flags = FEVAL_ENOENTOK|FEVAL_HISTORY;
+ flags = FEVAL_ENOENTOK|FEVAL_HISTORY|FEVAL_REGFILE;
return (_evalfile (filename, flags));
}
#endif /* HISTORY */
int
source_file (filename)
- char *filename;
+ const char *filename;
{
int flags;