<commit_before><?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE comref SYSTEM "comref.dtd">

<comref>
  <header>
    <copyright>
      <year>2007</year><year>2013</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      The contents of this file are subject to the Erlang Public License,
      Version 1.1, (the "License"); you may not use this file except in
      compliance with the License. You should have received a copy of the
      Erlang Public License along with this software. If not, it can be
      retrieved online at http://www.erlang.org/.

      Software distributed under the License is distributed on an "AS IS"
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
      the License for the specific language governing rights and limitations
      under the License.

    </legalnotice>

    <title>escript</title>
    <prepared></prepared>
    <docno></docno>
    <date></date>
    <rev></rev>
    <file>escript.xml</file>
  </header>
  <com>escript</com>
  <comsummary>Erlang scripting support</comsummary>
  <description>
    <p><c>escript</c> provides support for running short Erlang programs
      without having to compile them first and an easy way to retrieve the
      command line arguments.</p>
  </description>
  <funcs>
    <func>
      <name>script-name script-arg1 script-arg2...</name>
      <name>escript escript-flags script-name script-arg1 script-arg2...</name>
      <fsummary>Run a script written in Erlang</fsummary>
      <desc>
        <p><c>escript</c> runs a script written in Erlang.</p>
        <p>Here follows an example.</p>
        <pre>
$ <input>cat factorial</input>
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname factorial -mnesia debug verbose
main([String]) ->
    try
        N = list_to_integer(String),
        F = fac(N),
        io:format("factorial ~w = ~w\n", [N,F])
    catch
        _:_ ->
            usage()
    end;
main(_) ->
    usage().

usage() ->
    io:format("usage: factorial integer\n"),
    halt(1).

fac(0) -> 1;
fac(N) -> N * fac(N-1).
$ <input>factorial 5</input>
factorial 5 = 120
$ <input>factorial</input>
usage: factorial integer
$ <input>factorial five</input>
usage: factorial integer        </pre>
        <p>The header of the Erlang script in the example differs from
        a normal Erlang module.  The first line is intended to be the
        interpreter line, which invokes <c>escript</c>. However if you
        invoke the <c>escript</c> like this</p>
        <pre>
$ <input>escript factorial 5</input>        </pre>
        <p>the contents of the first line does not matter, but it
        cannot contain Erlang code as it will be ignored.</p>
        <p>The second line in the example, contains an optional
          directive to the <c>Emacs</c> editor which causes it to
          enter the major mode for editing Erlang source files. If the
          directive is present it must be located on the second
          line.</p><commit_msg>Add a chmod call in the CLI example<commit_after><?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE comref SYSTEM "comref.dtd">

<comref>
  <header>
    <copyright>
      <year>2007</year><year>2013</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      The contents of this file are subject to the Erlang Public License,
      Version 1.1, (the "License"); you may not use this file except in
      compliance with the License. You should have received a copy of the
      Erlang Public License along with this software. If not, it can be
      retrieved online at http://www.erlang.org/.

      Software distributed under the License is distributed on an "AS IS"
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
      the License for the specific language governing rights and limitations
      under the License.

    </legalnotice>

    <title>escript</title>
    <prepared></prepared>
    <docno></docno>
    <date></date>
    <rev></rev>
    <file>escript.xml</file>
  </header>
  <com>escript</com>
  <comsummary>Erlang scripting support</comsummary>
  <description>
    <p><c>escript</c> provides support for running short Erlang programs
      without having to compile them first and an easy way to retrieve the
      command line arguments.</p>
  </description>
  <funcs>
    <func>
      <name>script-name script-arg1 script-arg2...</name>
      <name>escript escript-flags script-name script-arg1 script-arg2...</name>
      <fsummary>Run a script written in Erlang</fsummary>
      <desc>
        <p><c>escript</c> runs a script written in Erlang.</p>
        <p>Here follows an example.</p>
        <pre>
$ <input>chmod u+x factorial</input>
$ <input>cat factorial</input>
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname factorial -mnesia debug verbose
main([String]) ->
    try
        N = list_to_integer(String),
        F = fac(N),
        io:format("factorial ~w = ~w\n", [N,F])
    catch
        _:_ ->
            usage()
    end;
main(_) ->
    usage().

usage() ->
    io:format("usage: factorial integer\n"),
    halt(1).

fac(0) -> 1;
fac(N) -> N * fac(N-1).
$ <input>./factorial 5</input>
factorial 5 = 120
$ <input>./factorial</input>
usage: factorial integer
$ <input>./factorial five</input>
usage: factorial integer
        </pre>
        <p>The header of the Erlang script in the example differs from
        a normal Erlang module.  The first line is intended to be the
        interpreter line, which invokes <c>escript</c>. However if you
        invoke the <c>escript</c> like this</p>
        <pre>
$ <input>escript factorial 5</input>        </pre>
        <p>the contents of the first line does not matter, but it
        cannot contain Erlang code as it will be ignored.</p>
        <p>The second line in the example, contains an optional
          directive to the <c>Emacs</c> editor which causes it to
          enter the major mode for editing Erlang source files. If the
          directive is present it must be located on the second
          line.</p>
{'fraction_non_alphanumeric': 0.11861910994764398, 'fraction_numerical': 0.008835078534031414, 'mean_word_length': 2.6692677070828332, 'pattern_counts': {'":': 0, '<': 161, '<?xml version=': 2, '>': 173, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1969432', 'n_tokens_mistral': 1876, 'n_tokens_neox': 1828, 'n_words': 661}