If command 'source' fails, do not continue a script, but
call for user input.
This commit is contained in:
parent
96d1badb0b
commit
fa116e46f2
|
|
@ -1590,15 +1590,26 @@ com_source(wordlist *wl)
|
||||||
if ((fp = inp_pathopen(tempfile, "w+")) == NULL) {
|
if ((fp = inp_pathopen(tempfile, "w+")) == NULL) {
|
||||||
perror(tempfile);
|
perror(tempfile);
|
||||||
cp_interactive = TRUE;
|
cp_interactive = TRUE;
|
||||||
return;
|
/* If we cannot open the temporary file, stop all further command execution */
|
||||||
|
#ifdef SHARED_MODULE
|
||||||
|
controlled_exit(1);
|
||||||
|
#else
|
||||||
|
cp_evloop(NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
while (wl) {
|
while (wl) {
|
||||||
if ((tp = inp_pathopen(wl->wl_word, "r")) == NULL) {
|
if ((tp = inp_pathopen(wl->wl_word, "r")) == NULL) {
|
||||||
|
fprintf(cp_err, "Command 'source' failed:\n");
|
||||||
perror(wl->wl_word);
|
perror(wl->wl_word);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
cp_interactive = TRUE;
|
cp_interactive = TRUE;
|
||||||
unlink(tempfile);
|
unlink(tempfile);
|
||||||
return;
|
/* If we cannot source the file, stop all further command execution */
|
||||||
|
#ifdef SHARED_MODULE
|
||||||
|
controlled_exit(1);
|
||||||
|
#else
|
||||||
|
cp_evloop(NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
while ((n = fread(buf, 1, BSIZE_SP, tp)) > 0)
|
while ((n = fread(buf, 1, BSIZE_SP, tp)) > 0)
|
||||||
fwrite(buf, 1, n, fp);
|
fwrite(buf, 1, n, fp);
|
||||||
|
|
@ -1611,8 +1622,15 @@ com_source(wordlist *wl)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
|
fprintf(cp_err, "Command 'source' failed:\n");
|
||||||
perror(wl->wl_word);
|
perror(wl->wl_word);
|
||||||
cp_interactive = TRUE;
|
cp_interactive = TRUE;
|
||||||
|
/* If we cannot source the file, stop all further command execution */
|
||||||
|
#ifdef SHARED_MODULE
|
||||||
|
controlled_exit(1);
|
||||||
|
#else
|
||||||
|
cp_evloop(NULL);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue