# HG changeset patch # User wenzelm # Date 1244394425 -7200 # Node ID 5333aa7390821d5a299497e091be2009ea92921e # Parent c4b74075fc172db446be86e0a2ce4c4af823db4a isabelle getenv: option -d; diff -r c4b74075fc17 -r 5333aa739082 doc-src/System/Thy/Misc.thy --- a/doc-src/System/Thy/Misc.thy Sat Jun 06 23:43:07 2009 +0200 +++ b/doc-src/System/Thy/Misc.thy Sun Jun 07 19:07:05 2009 +0200 @@ -85,6 +85,8 @@ Options are: -a display complete environment -b print values only (doesn't work for -a) + -d FILE dump complete environment to FILE + (null terminated entries) Get value of VARNAMES from the Isabelle settings. \end{ttbox} @@ -95,6 +97,10 @@ Normally, output is a list of lines of the form @{text name}@{verbatim "="}@{text value}. The @{verbatim "-b"} option causes only the values to be printed. + + Option @{verbatim "-d"} produces a dump of the complete environment + to the specified file. Entries are terminated by the ASCII null + character, i.e.\ the C string terminator. *} diff -r c4b74075fc17 -r 5333aa739082 doc-src/System/Thy/document/Misc.tex --- a/doc-src/System/Thy/document/Misc.tex Sat Jun 06 23:43:07 2009 +0200 +++ b/doc-src/System/Thy/document/Misc.tex Sun Jun 07 19:07:05 2009 +0200 @@ -110,6 +110,8 @@ Options are: -a display complete environment -b print values only (doesn't work for -a) + -d FILE dump complete environment to FILE + (null terminated entries) Get value of VARNAMES from the Isabelle settings. \end{ttbox} @@ -118,7 +120,11 @@ environment that Isabelle related programs are run in. This usually contains much more variables than are actually Isabelle settings. Normally, output is a list of lines of the form \isa{name}\verb|=|\isa{value}. The \verb|-b| option - causes only the values to be printed.% + causes only the values to be printed. + + Option \verb|-d| produces a dump of the complete environment + to the specified file. Entries are terminated by the ASCII null + character, i.e.\ the C string terminator.% \end{isamarkuptext}% \isamarkuptrue% % diff -r c4b74075fc17 -r 5333aa739082 lib/Tools/getenv --- a/lib/Tools/getenv Sat Jun 06 23:43:07 2009 +0200 +++ b/lib/Tools/getenv Sun Jun 07 19:07:05 2009 +0200 @@ -17,6 +17,8 @@ echo " Options are:" echo " -a display complete environment" echo " -b print values only (doesn't work for -a)" + echo " -d FILE dump complete environment to FILE" + echo " (null terminated entries)" echo echo " Get value of VARNAMES from the Isabelle settings." echo @@ -30,8 +32,9 @@ ALL="" BASE="" +DUMP="" -while getopts "ab" OPT +while getopts "abd:" OPT do case "$OPT" in a) @@ -40,6 +43,9 @@ b) BASE=true ;; + d) + DUMP="$OPTARG" + ;; \?) usage ;; @@ -68,3 +74,8 @@ fi done fi + +if [ -n "$DUMP" ]; then + exec perl -w -e 'for $key (keys %ENV) { print $key, "=", $ENV{$key}, "\x00"; }' > "$DUMP" +fi +