Powershell

Line continuation (and termination for that matter) characters are not required that often.

  • An open brace { , parenthesis ( , or square bracket [ will allow for continuation across multiple lines until the block is closed by the corresponding } ) ]
  • A trailing comma (the array operator) will allow for a line break until the next array member
  • Single and double-quotes will work as well, but I really don’t recommend doing so just because its unexpected and confusing to read the code. If you want to do this, instead use the “here string” feature and enclose your multi-line string with @” and “@

So you can do this without a single line-continuation character (a trailing back-tick ` )

function test {
  param (
    $firstname,
    $lastname
  )
  (get-process) [
    1
  ]
  write-host "$firstname
$lastname" # don't do this, or kittens will die
}

: http://halr9000.com/article/473

No comments yet.

  • Microblog

  • Recent Posts

  • Recent Comments

  • meta

  • PowerShell Blogroll