110 lines
5.3 KiB
HTML
110 lines
5.3 KiB
HTML
|
<?xml version="1.0" encoding="iso-8859-1" ?>
|
||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<!--http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd-->
|
||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||
|
>
|
||
|
<head><title>39 System.Environment</title>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||
|
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" />
|
||
|
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" />
|
||
|
<!-- 2,html,xhtml -->
|
||
|
<meta name="src" content="haskell.tex" />
|
||
|
<meta name="date" content="2010-07-20 13:11:00" />
|
||
|
<link rel="stylesheet" type="text/css" href="haskell.css" />
|
||
|
</head><body
|
||
|
>
|
||
|
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
|
||
|
href="haskellch40.html" >next</a>] [<a
|
||
|
href="haskellch38.html" >prev</a>] [<a
|
||
|
href="haskellch38.html#tailhaskellch38.html" >prev-tail</a>] [<a
|
||
|
href="#tailhaskellch39.html">tail</a>] [<a
|
||
|
href="haskellpa2.html#haskellch39.html" >up</a>] </p></div>
|
||
|
<h2 class="chapterHead"><span class="titlemark">Chapter 39</span><br /><a
|
||
|
id="x47-31800039"></a><span
|
||
|
class="pcrr7t-">System.Environment</span></h2>
|
||
|
<div class="quote">
|
||
|
|
||
|
|
||
|
|
||
|
<div class="verbatim" id="verbatim-467">
|
||
|
module System.Environment (
|
||
|
 <br />    getArgs,  getProgName,  getEnv
|
||
|
 <br />  ) where
|
||
|
</div>
|
||
|
<p class="noindent"></div>
|
||
|
<dl><dt class="haddockdesc">
|
||
|
<!--tex4ht:inline--><div class="tabular"> <table id="TBL-628" class="tabular"
|
||
|
cellspacing="0" cellpadding="0" rules="groups"
|
||
|
><colgroup id="TBL-628-1g"><col
|
||
|
id="TBL-628-1" /></colgroup><tr
|
||
|
style="vertical-align:baseline;" id="TBL-628-1-"><td style="white-space:nowrap; text-align:left;" id="TBL-628-1-1"
|
||
|
class="td11"><span
|
||
|
class="pcrb7t-">getArgs</span><span
|
||
|
class="pcrb7t-"> ::</span><span
|
||
|
class="pcrb7t-"> IO</span><span
|
||
|
class="pcrb7t-"> [String] </span></td>
|
||
|
</tr></table> </div> <dd class="haddockdesc">
|
||
|
Computation <span
|
||
|
class="pcrr7t-">getArgs</span><a
|
||
|
id="dx47-318001"></a> returns a list of the program’s command line arguments (not including the
|
||
|
program name).
|
||
|
</dl>
|
||
|
<dl> <dt class="haddockdesc">
|
||
|
<!--tex4ht:inline--><div class="tabular"> <table id="TBL-629" class="tabular"
|
||
|
cellspacing="0" cellpadding="0" rules="groups"
|
||
|
><colgroup id="TBL-629-1g"><col
|
||
|
id="TBL-629-1" /></colgroup><tr
|
||
|
style="vertical-align:baseline;" id="TBL-629-1-"><td style="white-space:nowrap; text-align:left;" id="TBL-629-1-1"
|
||
|
class="td11"><span
|
||
|
class="pcrb7t-">getProgName</span><span
|
||
|
class="pcrb7t-"> ::</span><span
|
||
|
class="pcrb7t-"> IO</span><span
|
||
|
class="pcrb7t-"> String </span></td>
|
||
|
</tr></table> </div> <dd class="haddockdesc">
|
||
|
Computation <span
|
||
|
class="pcrr7t-">getProgName</span><a
|
||
|
id="dx47-318002"></a> returns the name of the program as it was invoked.
|
||
|
<p class="noindent"> However, this is hard-to-impossible to implement on some non-Unix OSes, so instead, for maximum
|
||
|
portability, we just return the leafname of the program as invoked. Even then there are some differences
|
||
|
between platforms: on Windows, for example, a program invoked as foo is probably really <span
|
||
|
class="pcrr7t-">FOO.EXE</span>,
|
||
|
and that is what <span
|
||
|
class="pcrr7t-">getProgName</span><a
|
||
|
id="dx47-318003"></a> will return.
|
||
|
</dl>
|
||
|
<dl> <dt class="haddockdesc">
|
||
|
<!--tex4ht:inline--><div class="tabular"> <table id="TBL-630" class="tabular"
|
||
|
cellspacing="0" cellpadding="0" rules="groups"
|
||
|
><colgroup id="TBL-630-1g"><col
|
||
|
id="TBL-630-1" /></colgroup><tr
|
||
|
style="vertical-align:baseline;" id="TBL-630-1-"><td style="white-space:nowrap; text-align:left;" id="TBL-630-1-1"
|
||
|
class="td11"><span
|
||
|
class="pcrb7t-">getEnv</span><span
|
||
|
class="pcrb7t-"> ::</span><span
|
||
|
class="pcrb7t-"> String</span><span
|
||
|
class="pcrb7t-"> -></span><span
|
||
|
class="pcrb7t-"> IO</span><span
|
||
|
class="pcrb7t-"> String </span></td>
|
||
|
</tr></table> </div> <dd class="haddockdesc">
|
||
|
Computation <span
|
||
|
class="pcrr7t-">getEnv</span><a
|
||
|
id="dx47-318004"></a><span
|
||
|
class="pcrr7t-">var </span>returns the value of the environment variable <span
|
||
|
class="pcrr7t-">var</span>.
|
||
|
<p class="noindent"> This computation may fail with:
|
||
|
<ul class="itemize1">
|
||
|
<li class="itemize"><span
|
||
|
class="pcrr7t-">System.IO.Error.isDoesNotExistError </span>if the environment variable does not exist.
|
||
|
</li></ul>
|
||
|
</dl>
|
||
|
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a
|
||
|
href="haskellch40.html" >next</a>] [<a
|
||
|
href="haskellch38.html" >prev</a>] [<a
|
||
|
href="haskellch38.html#tailhaskellch38.html" >prev-tail</a>] [<a
|
||
|
href="haskellch39.html" >front</a>] [<a
|
||
|
href="haskellpa2.html#haskellch39.html" >up</a>] </p></div>
|
||
|
<p class="noindent"> <a
|
||
|
id="tailhaskellch39.html"></a>
|
||
|
</body></html>
|