title: Colored ghci output on PowerShell
body: <p>Some time ago, I stumbled upon <a href="https://github.com/rhysd/ghci-color/raw/master/ghci-color" rel="nofollow noreferrer">this</a>. However, since I'm using Windows, I'm unable to run it. Hence, I decided to create a <code>.ps1</code> version of it so I would be able to run it in PowerShell. However I've been getting the following error:</p>
  <pre><code>Line |
    25 |  Invoke-Expression (Get-Command ghci).Path $args 2&gt;&amp;1 | `
       |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | A positional parameter cannot be found that accepts argument 'System.Object[]'.
  </code></pre>
  <p>My complete code can be found <a href="https://pastebin.com/P0Y6EdYu" rel="nofollow noreferrer">here</a> and the specific part where the error lies is as follows:</p>
  <pre><code>Invoke-Expression (Get-Command ghci).Path $args 2&gt;&amp;1 | `
      sed &quot;$load_failed `
           $load_done `
           $no_instance `
           $interactive `
           $double_colon ` 
           $right_arrow `
           $right_arrow2 `
           $parenthesis ` 
           $left_blacket `
           $right_blacket `
           $double_colon `
           $calc_operators `
           $string `
           $char&quot; 
  </code></pre>
  <p>Also, the original code I'm trying to convert, written in shell script(.sh), is as follows</p>
  <pre class="lang-sh prettyprint-override"><code>exec &quot;`which ghc`&quot; --interactive ${1+&quot;$@&quot;} 2&gt;&amp;1 |\
      sed &quot;$load_failed\
           $load_done\
           $no_instance\
           $interactive\
           $double_colon\
           $right_arrow\
           $right_arrow2\
           $parenthesis\
           $left_blacket\
           $right_blacket\
           $double_colon\
           $calc_operators\
           $string\
           $char&quot;
  </code></pre>
  <p>And I'd like to clarify that I have installed <code>sed</code> on my PowerShell. Thank you in advance.</p>
  <h2><code>Update</code></h2>
  <p>I've managed to resolve the earlier mentioned error thanks to <a href="https://stackoverflow.com/questions/71906991/colored-ghci-output-on-powershell#answer-71912680">@Mike Anthony</a>'s suggestion to use <code>@args</code> instead of <code>$args</code>. However, I seem to be getting another error as shown below:</p>
  <pre><code>sed: 13: &quot;s/^Failed, modules load ...&quot;: unbalanced brackets ([])
  </code></pre>
  <p>Apparently there seems to be an error with the following part of my code:</p>
  <pre><code>$load_failed=&quot;s/^Failed, modules loaded:/$RED&amp;$RESET/;&quot;
  $load_done=&quot;s/done./$GREEN&amp;$RESET/g;&quot;
  $double_colon=&quot;s/::/$PURPLE&amp;$RESET/g;&quot;
  $right_arrow=&quot;s/\-&gt;/$PURPLE&amp;$RESET/g;&quot;
  $right_arrow2=&quot;s/=&gt;/$PURPLE&amp;$RESET/g;&quot;
  $calc_operators=&quot;s/[+\-\/*]/$PURPLE&amp;$RESET/g;&quot;
  $char=&quot;s/'\\?.'/$RED&amp;$RESET/g;&quot;
  $string=&quot;s/`&quot;[^`&quot;]*`&quot;/$RED&amp;$RESET/g;&quot;
  $parenthesis=&quot;s/[{}()]/$BLUE&amp;$RESET/g;&quot;
  $left_blacket=&quot;s/\[\([^09]\)/$BLUE[$RESET\1/g;&quot;
  $right_blacket=&quot;s/\]/$BLUE&amp;$RESET/g;&quot;
  $no_instance=&quot;s/^\s*No instance/$RED&amp;$RESET/g;&quot;
  $interactive=&quot;s/^&lt;[^&gt;]*&gt;/$RED&amp;$RESET/g;&quot;
  </code></pre>
  <p>and more specifically:</p>
  <pre><code>$string=&quot;s/`&quot;[^`&quot;]*`&quot;/$RED&amp;$RESET/g;&quot;
  </code></pre>
  <p>The original code written in shell script reads:</p>
  <pre><code>string=&quot;s/\&quot;[^\&quot;]*\&quot;/$RED&amp;$RESET/g;&quot;
  </code></pre>
  <p>I'm really confused where the unbalanced brackets are so any help would be greatly appreciated.</p>