Skip to content

Commit

Permalink
Merge branch 'obsd-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAdam committed Dec 18, 2019
2 parents 4223293 + ef54a08 commit d0cd68d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cmd-source-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
char *pattern, *cwd;
const char *path, *error;
glob_t g;
int i;
int i, result;
u_int j;

cdata = xcalloc(1, sizeof *cdata);
Expand Down Expand Up @@ -157,9 +157,15 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
xasprintf(&pattern, "%s/%s", cwd, path);
log_debug("%s: %s", __func__, pattern);

if (glob(pattern, 0, NULL, &g) != 0) {
error = strerror(errno);
if (errno != ENOENT || (~flags & CMD_PARSE_QUIET)) {
if ((result = glob(pattern, 0, NULL, &g)) != 0) {
if (result != GLOB_NOMATCH ||
(~flags & CMD_PARSE_QUIET)) {
if (result == GLOB_NOMATCH)
error = strerror(ENOENT);
else if (result == GLOB_NOSPACE)
error = strerror(ENOMEM);
else
error = strerror(EINVAL);
cmdq_error(item, "%s: %s", path, error);
retval = CMD_RETURN_ERROR;
}
Expand Down

0 comments on commit d0cd68d

Please sign in to comment.