2 * printenv -- minimal builtin clone of BSD printenv(1).
4 * usage: printenv [varname]
9 Copyright (C) 1999-2009 Free Software Foundation, Inc.
11 This file is part of GNU Bash.
12 Bash is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
17 Bash is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with Bash. If not, see <http://www.gnu.org/licenses/>.
31 #include "bashgetopt.h"
34 extern char **export_env;
37 printenv_builtin (list)
44 reset_internal_getopt ();
45 while ((opt = internal_getopt (list, "")) != -1)
59 maybe_make_export_env (); /* this allows minimal code */
60 for (envp = export_env; *envp; envp++)
61 printf ("%s\n", *envp);
62 return (EXECUTION_SUCCESS);
65 /* printenv varname */
66 var = find_variable (list->word->word);
67 if (var == 0 || (exported_p (var) == 0))
68 return (EXECUTION_FAILURE);
71 print_var_function (var);
73 print_var_value (var, 0);
76 return (EXECUTION_SUCCESS);
79 char *printenv_doc[] = {
80 "Display environment.",
82 "Print names and values of environment variables",
86 struct builtin printenv_struct = {