You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
546 B

/* See LICENSE file for copyright and license details. */
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
extern char **environ;
static void
usage(void)
{
eprintf("usage: %s [var ...]\n", argv0);
}
int
main(int argc, char *argv[])
{
char *var;
int ret = 0;
ARGBEGIN {
default:
usage();
} ARGEND
if (!argc) {
for (; *environ; environ++)
puts(*environ);
} else {
for (; *argv; argc--, argv++) {
if ((var = getenv(*argv)))
puts(var);
else
ret = 1;
}
}
return fshut(stdout, "<stdout>") ? 2 : ret;
}