Is there a “strict” case-sensitive syntax mode?

Welcome Forums General PowerShell Q&A Is there a “strict” case-sensitive syntax mode?

Viewing 2 reply threads
  • Author
    • #215949
      Topics: 1
      Replies: 0
      Points: 11
      Rank: Member

      I sort of understand the reasoning behind the decision to make the powershell syntax case-insensitive but when writing serious and complex scripts it is a terrible problem. Everybody is writing in his own style and reading and comprehending all that mess becomes mission impossible. Is there a way to turn on a “strict” mode which would require to use exact casing and ideally the long versions of the commands like Select-Object, Push-Location and so on?

      If there is no such feature, is possible to request implementing it?

    • #215955
      Topics: 5
      Replies: 260
      Points: 1,039
      Helping Hand
      Rank: Community Hero

      I don’t think there is any quick easy way to make PS globally case sensitive.  You can force case sensitivity in certain situations like using comparison operators such as -ceq instead of -eq.  Also, you might want to look at Set-StrictMode to eliminate what some (myself included) might consider bad coding practices that PS lets you get away with.

    • #215961
      Topics: 17
      Replies: 1956
      Points: 4,010
      Helping Hand
      Rank: Community Hero

      There is a Strict Mode ( Strict mode is more for strongly-typed code, but not the case of the letters. It checks things like Gci (alias) should be Get-ChildItem. get-childitem would most likely be fine as long as it’s not an alias. Where should be Where-Object, but where-object is fine.

      Editors can have preferences like brackets, if everyone is using Visual Studio Code, you can force some settings. In general, I don’t think you can force Title case or something specific like this.

Viewing 2 reply threads
  • The topic ‘Is there a “strict” case-sensitive syntax mode?’ is closed to new replies.