2 * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * @brief printenv: Print out environment variables
29 #include <environment.h>
31 static int do_printenv (cmd_tbl_t
*cmdtp
, int argc
, char *argv
[])
33 struct variable_d
*var
;
34 struct env_context
*c
, *current_c
;
37 const char *val
= getenv(argv
[1]);
39 printf("%s=%s\n", argv
[1], val
);
42 printf("## Error: \"%s\" not defined\n", argv
[1]);
46 current_c
= get_current_context();
47 var
= current_c
->local
->next
;
50 printf("%s=%s\n", var_name(var
), var_val(var
));
55 c
= get_current_context();
57 var
= c
->global
->next
;
59 printf("%s=%s\n", var_name(var
), var_val(var
));
68 static const __maybe_unused
char cmd_printenv_help
[] =
69 "\n - print values of all environment variables\n"
71 " - print value of environment variable 'name'\n";
74 U_BOOT_CMD_START(printenv
)
76 .usage
= "print environment variables",
77 U_BOOT_CMD_HELP(cmd_printenv_help
)
81 * @page printenv_command printenv
83 * Usage: printenv [\<name>]
85 * Print environment variables.
86 * If \<name> was given, it prints out its content if the environment variable
89 * Without the \<name> argument all current environment variables are printed.