How Ecasound Parses Escaped Chain Arguments

This article explains how Ecasound processes escaped characters within chain operator arguments. It covers how the internal tokenizer recognizes delimiters, handles backslash escape sequences, and interacts with shell-level parsing, enabling users to pass complex string arguments—such as filenames with spaces or plugins requiring literal commas—without breaking parameter processing.

The Role of Delimiters in Chain Operators

In Ecasound, chain operators are applied to audio chains using options like -el, -ea, or -ef3, followed by parameters separated by commas (,). For example, in -ea:100,50, the comma acts as a delimiter separating the gain values for different channels.

When an argument must contain a literal delimiter—such as a comma within a string parameter, a colon, or quotation marks—Ecasound requires an escape mechanism so the internal parser does not misinterpret the character as a boundary between distinct arguments.

The Backslash as an Escape Character

Ecasound uses the backslash (\) as its escape character during argument tokenization:

  1. State-Based Tokenization: As the parser iterates through the argument string character by character, encountering a backslash shifts the tokenizer into an "escape state."
  2. Literal Interpretation: The character immediately following the backslash is treated as a raw, literal character. It is appended directly to the current parameter buffer rather than being evaluated as a structural token (like a comma , or a closing quote).
  3. Backslash Removal: The backslash itself is stripped from the finalized argument string. For example, the sequence \, results in a literal , stored inside the single argument value.
  4. Escaping the Escape Character: To pass an actual backslash into an operator argument, two backslashes (\\) must be used; the parser consumes the first and retains the second.

Shell Interpretation vs. Ecasound Parsing

A frequent point of confusion when working with escaped characters in Ecasound is the interaction between the operating system's shell (such as Bash or Zsh) and Ecasound's internal parser.

Before Ecasound receives an argument string, the shell processes its own escape rules. If a command is entered as:

-ea:value\,test

The shell strips the backslash before launching Ecasound, causing Ecasound to see -ea:value,test and split it into two separate arguments.

To ensure the backslash reaches Ecasound's parser, you must either:

Quoting Mechanisms Inside Ecasound

In addition to backslash escaping, Ecasound supports double-quote (") grouping within chain arguments to enclose values that contain spaces or special characters. When quotes are used: