Difference between revisions of "Batch Conversion Limitations"

From eXo Wiki
Jump to navigation Jump to search
Line 2: Line 2:


=== Indenting nested if statements and for loops is necessary. ===
=== Indenting nested if statements and for loops is necessary. ===
With the limitations of tooling, nested statements that written without indentation, such as the below example, will fail to convert:
With the limitations of tooling, nested statements that written without indentation will fail to convert.
 
Example that fails to convert:
<pre>
<pre>
if [...] (
if [...] (
Line 14: Line 16:
Instead, anything that is nested should have spacing to indicate the level of nesting. The closing parentheses are especially important.
Instead, anything that is nested should have spacing to indicate the level of nesting. The closing parentheses are especially important.


Example that correctly converts:
Example that successfully converts:
<pre>
<pre>
if [...] (
if [...] (
Line 26: Line 28:
=== Labels must never be placed inside of loops or conditions. ===
=== Labels must never be placed inside of loops or conditions. ===
The converted goto function has been designed to work through stack frames for Linux and MacOS. For this reason, a label must never be placed inside of a loop or condition. Such code will fail to convert.
The converted goto function has been designed to work through stack frames for Linux and MacOS. For this reason, a label must never be placed inside of a loop or condition. Such code will fail to convert.
Example:
 
Example that fails to convert:
<pre>
<pre>
if exist file2.txt goto mylabel
if exist file2.txt goto mylabel

Revision as of 11:51, 21 April 2026

For batch files to successfully convert into bash files for Linux and MacOS, there are some limitations for how they can be written. This page is to ensure that team members writing batch files are aware of some of those limitations.

Indenting nested if statements and for loops is necessary.

With the limitations of tooling, nested statements that written without indentation will fail to convert.

Example that fails to convert:

if [...] (
some command
if [...] (
some command
)
)

Instead, anything that is nested should have spacing to indicate the level of nesting. The closing parentheses are especially important.

Example that successfully converts:

if [...] (
  some command
  if [...] (
    some command
  )
)

Labels must never be placed inside of loops or conditions.

The converted goto function has been designed to work through stack frames for Linux and MacOS. For this reason, a label must never be placed inside of a loop or condition. Such code will fail to convert.

Example that fails to convert:

if exist file2.txt goto mylabel
if exist .\mydir\file1.txt (
  echo file1 exists
  :mylabel
  echo This does not convert
)

Example that successfully converts:

if exist file2.txt goto mylabel
if exist .\mydir\file1.txt (
  echo file1 exists
  goto mylabel
)
goto skip
:mylabel
echo This does not converts
:skip