<doc>
  <legacy_id>1940</legacy_id>
  <name>shell</name>
  <type>function</type>
  <syntax>
    <example>the shell of <i>commandLine</i></example>
    <example>shell(<i>commandLine</i>)</example>
  </syntax>
  <library></library>
  <objects>
  </objects>
  <synonyms>
  </synonyms>
  <classification>
  </classification>
  <references>
    <function tag="screenName">screenName Function</function>
    <command tag="launch">launch Command</command>
    <property tag="hideConsoleWindows">hideConsoleWindows Property</property>
  </references>
  <history>
    <introduced version="1.0">Added.</introduced>
    <changed version="2.0"></changed>
  </history>
  <platforms>
    <mac/>
    <windows/>
    <linux/>
  </platforms>
  <classes>
    <desktop/>
    <server/>
    <web/>
  </classes>
  <security>
  </security>
  <summary>Runs a <function tag="shell">shell</function> command and returns its output.</summary>
  <examples>
    <example>shell("ls -l *.txt") <code><i>-- returns a listing of the current dir on Unix</i></code></example>
    <example>shell(field "Command")</example>
    <example>shell("attrib main.rev +R")</example>
  </examples>
  <description>
    <p>Use the <b>shell</b> <control_st tag="function">function</control_st> to <glossary tag="execute">execute</glossary> a <glossary tag="command line">command line</glossary>.</p><p/><p><b>Parameters:</b></p><p>The <i>commandLine</i> is a <keyword tag="string">string</keyword> or an <glossary tag="expression">expression</glossary> that <glossary tag="evaluate">evaluates</glossary> to a <keyword tag="string">string</keyword>.</p><p/><p><b>Value:</b></p><p>The <b>shell</b> <control_st tag="function">function</control_st> <glossary tag="return">returns</glossary> a <keyword tag="string">string</keyword>.</p><p/><p><b>Comments:</b></p><p>The <i>commandLine</i> must be a valid <function tag="shell">shell</function> command on the current operating system. Use the <property tag="shellCommand">shellCommand</property> <glossary tag="property">property</glossary> to set the <function tag="shell">shell</function> you want to use. The command is executed in the current <property tag="defaultFolder">defaultFolder</property>.</p><p/><p><code/><b>Note:</b><code/> If you use a <glossary tag="file path">file path</glossary> in the <function tag="shell">shell</function> command on a Windows system, the <glossary tag="file path">file path</glossary> must be in Windows form, not the Unix-style <glossary tag="file path">file paths</glossary> that LiveCode uses internally.</p><p/><p>The value returned by the <b>shell</b> <control_st tag="function">function</control_st> is the result of the <i>commandLine</i>, including any <href tag="../dictionary/error_message.xml">error messages</href> the <i>commandLine</i> generates. (On <glossary tag="Unix">Unix systems</glossary>, the <keyword tag="stdout">stdout</keyword> and <keyword tag="stderr">stderr</keyword> are combined to create the <glossary tag="return value">return value</glossary>.) The current <glossary tag="handler">handler</glossary> pauses until the <function tag="shell">shell</function> returns its result. If the command was successful but did not return anything, the <b>shell</b> <control_st tag="function">function</control_st> returns empty.</p><p/><p>The <b>result</b> is set to the shell command's exit code.</p><p/><p>To prevent a console window from appearing when the shell command is executed, set the <b>hideConsoleWindows</b> property to true.</p><p/><p><code/><img src="202651"/> <b>Tip:</b><code/> If you are having problems with the <function tag="shell">shell</function> <control_st tag="function">function</control_st>, try <glossary tag="execute">executing</glossary> the <i>commandLine</i> at your operating system's <function tag="shell">shell</function> prompt. (For example, on an <glossary tag="OS X">OS X system</glossary>, try executing the <i>commandLine</i> in the Terminal window.) If a <i>commandLine</i> does not work at the <function tag="shell">shell</function> prompt, it won't work with the <function tag="shell">shell</function> <control_st tag="function">function</control_st> either, so trying this can be useful when <glossary tag="debug">debugging</glossary>.</p><p/><p><b>Changes:</b></p><p>Support for using the <b>shell</b> <glossary tag="command">command</glossary> on <glossary tag="OS X">OS X systems</glossary> was added in version 2.0.</p><p/><p>In version 2.0 and later, the <b>shell</b> <control_st tag="function">function</control_st> returns empty if a <function tag="shell">shell</function> command (that does not normally return any data) was successful. In previous versions, the <b>shell</b> <control_st tag="function">function</control_st> returned zero in this case.</p>
  </description>
</doc>