summaryrefslogtreecommitdiffstats
path: root/lib/shell.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/shell.c (renamed from libmisc/shell.c)20
1 files changed, 11 insertions, 9 deletions
diff --git a/libmisc/shell.c b/lib/shell.c
index 7c67500..25ef3e3 100644
--- a/libmisc/shell.c
+++ b/lib/shell.c
@@ -15,6 +15,9 @@
#include <errno.h>
#include "prototypes.h"
#include "defines.h"
+#include "string/sprintf.h"
+
+
extern char **newenvp;
extern size_t newenvc;
@@ -30,10 +33,10 @@ extern size_t newenvc;
int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
{
- char arg0[1024];
- int err;
+ int err;
+ char arg0[1024];
- if (file == (char *) 0) {
+ if (file == NULL) {
errno = EINVAL;
return errno;
}
@@ -44,9 +47,8 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
* that. So, we determine the 0'th entry only if they
* don't want to tell us what it is themselves.
*/
- if (arg == (char *) 0) {
- (void) snprintf (arg0, sizeof arg0, "-%s", Basename (file));
- arg0[sizeof arg0 - 1] = '\0';
+ if (arg == NULL) {
+ SNPRINTF(arg0, "-%s", Basename(file));
arg = arg0;
}
@@ -55,7 +57,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
* able to figure out what we are up to without too much
* grief.
*/
- (void) execle (file, arg, (char *) 0, envp);
+ (void) execle (file, arg, (char *) NULL, envp);
err = errno;
if (access (file, R_OK|X_OK) == 0) {
@@ -63,7 +65,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
* Assume this is a shell script (with no shebang).
* Interpret it with /bin/sh
*/
- (void) execle (SHELL, "sh", "-", file, (char *)0, envp);
+ (void) execle (SHELL, "sh", "-", file, (char *) NULL, envp);
err = errno;
}
@@ -72,7 +74,7 @@ int shell (const char *file, /*@null@*/const char *arg, char *const envp[])
* how to execute this stupid shell, so I might as well give
* up in disgust ...
*/
- (void) snprintf (arg0, sizeof arg0, _("Cannot execute %s"), file);
+ SNPRINTF(arg0, _("Cannot execute %s"), file);
errno = err;
perror (arg0);
return err;