forked from Imagelibrary/rtems
* libmisc/shell/cmds.c: Make rtems_shell_main_monitor static. * libmisc/shell/main_alias.c: Make rtems_shell_rtems_main_alias static. * libmisc/shell/main_blksync.c: Make rtems_shell_main_blksync static. * libmisc/shell/main_cat.c: Make rtems_shell_main_cat static. * libmisc/shell/main_chdir.c: Make rtems_shell_main_chdir static. * libmisc/shell/main_chmod.c: Make rtems_shell_main_chmod static. * libmisc/shell/main_chroot.c: Make rtems_shell_main_chroot static. * libmisc/shell/main_cp.c: Make rtems_shell_cp_exit, rtems_shell_main_cp static. * libmisc/shell/main_cpuuse.c: Make rtems_shell_main_cpuuse static. * libmisc/shell/main_date.c: Make rtems_shell_main_date static. * libmisc/shell/main_dd.c: Make rtems_shell_main_dd static. * libmisc/shell/main_echo.c: Make rtems_shell_main_echo static. * libmisc/shell/main_getenv.c: Make rtems_shell_main_getenv static. * libmisc/shell/main_halt.c: Make rtems_shell_main_halt static.
50 lines
913 B
C
50 lines
913 B
C
/*
|
|
* Get an environment vairable.
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
#include <rtems.h>
|
|
#include <rtems/shell.h>
|
|
#include "internal.h"
|
|
|
|
static int rtems_shell_main_getenv(int argc, char *argv[])
|
|
{
|
|
char* string;
|
|
|
|
if (argc != 2)
|
|
{
|
|
printf ("error: only argument is the variable name\n");
|
|
return 1;
|
|
}
|
|
|
|
string = getenv (argv[1]);
|
|
|
|
if (!string)
|
|
{
|
|
printf ("error: %s not found\n", argv[1]);
|
|
return 1;
|
|
}
|
|
|
|
printf ("%s\n", string);
|
|
|
|
return 0;
|
|
}
|
|
|
|
rtems_shell_cmd_t rtems_shell_GETENV_Command = {
|
|
"getenv", /* name */
|
|
"getenv [var]", /* usage */
|
|
"misc", /* topic */
|
|
rtems_shell_main_getenv, /* command */
|
|
NULL, /* alias */
|
|
NULL /* next */
|
|
};
|