size_t i;
if ((i = getindex(name)) == aliases.size) return NULL;
+
return aliases.entries[i].value;
}
struct entry *entry;
if ((i = getindex(name)) == aliases.size) return 0;
- entry = &aliases.entries[i];
+
+ entry = aliases.entries + i;
memmove(entry, entry + 1, (--aliases.size - i) * sizeof*entry);
for (; i < aliases.size; ++i, ++entry)
entry->value = (void *)entry->value - sizeof*entry;
*end = '\0';
}
- entry = &aliases.entries[i = getindex(args[1])];
+ entry = aliases.entries + (i = getindex(args[1]));
if (i == aliases.size) {
strcpy(entry->name, args[1]);
++aliases.size;
bgaction = (struct sigaction){.sa_handler = sigchldbghandler};
for (i = 0; i < MAXBG - 1; ++i)
- bgjobs.entries[i].next = &bgjobs.entries[i + 1];
+ bgjobs.entries[i].next = bgjobs.entries + i + 1;
bgjobs.free = bgjobs.entries;
}
int peekbg(struct bgjob *job) {
if (bgjobs.active && job) *job = bgjobs.active->job;
-
return bgjobs.active != NULL;
}
fprintf(stderr, "usage: %s", program);
if (options) fprintf(stderr, " %s", options);
fputc('\n', stderr);
-
return EXIT_FAILURE;
}
if (numargs < 2) return usage(args[0], "command [args ...]");
clear(&c);
- memcpy(c.tokens, &args[1], (numargs - 1) * sizeof*args);
+ memcpy(c.tokens, args + 1, (numargs - 1) * sizeof*args);
strcpy(c.current.name, args[1]);
if (!(c.current.builtin = getbuiltin(args[1]))
&& !(c.current.path = getpath(c.current.name))) {
/* execute() is guaranteed not to return, this statement just appeases the
* compiler */
- exit(EXIT_SUCCESS);
+ exit(EXIT_FAILURE);
}
if (numargs != 1) return usage(args[0], NULL);
deinit();
+
exit(EXIT_SUCCESS);
}
default:
return usage(args[0], "[verbose | quiet]");
}
-
return EXIT_SUCCESS;
}
default:
return usage(args[0], "name [value]");
}
-
return EXIT_SUCCESS;
}
int unalias(char **args, size_t numargs) {
if (numargs != 2) return usage(args[0], "name");
-
return removealias(args[1]) ? EXIT_SUCCESS : EXIT_FAILURE;
}
int unset(char **args, size_t numargs) {
if (numargs != 2) return usage(args[0], "name");
- if (unsetenv(args[1]) != -1) return EXIT_SUCCESS;
+ if (unsetenv(args[1]) == -1) {
+ note("Unable to unset `%s'", args[1]);
+ return EXIT_FAILURE;
+ }
- note("Unable to unset `%s'", args[1]);
- return EXIT_FAILURE;
+ return EXIT_SUCCESS;
}
if (errno != ENOENT) note("Unable to expand `%s'", file); else errno = 0;
return NULL;
}
- if (exists(path)) return path;
- return NULL;
+ return exists(path) ? path : NULL;
}
int which(char **args, size_t numargs) {
putchar('&');
default:
putchar('\n');
- }
+ }
}
islist = c->previous.term > BG || c->current.term > BG;
return quit(c);
}
jobid = pipeid;
- } else if (!c->r && (c->current.builtin = getbuiltin(c->current.name))) {
+ } else if (c->current.builtin && !c->r) {
status = c->current.builtin(c->tokens, c->numtokens);
cpid = 0;
} else if ((jobid = cpid = fork()) == -1) {
note("Unable to append trailing slash to $PWD$");
if (shlvl == 1
- && setenv("PATH", "/usr/local/bin/:/usr/local/sbin/:"
- "/usr/bin/:/usr/sbin/:/bin/:/sbin/", 1) == -1)
+ && setenv("PATH", "/usr/local/bin/:/usr/local/sbin/"
+ ":/usr/bin/:/usr/sbin/:/bin/:/sbin/", 1) == -1)
note("Unable to initialize $PATH$");
getcolumns();
} degree;
static char buffer[MAXCHARS + 1];
- if (!*token) return "\"\"";
+ if (!token[0]) return "\"\"";
degree = NONE;
for (p = token; *p; ++p) switch(*p) {