Welcome › Forums › General PowerShell Q&A › Is there a “strict” case-sensitive syntax mode?
- This topic has 2 replies, 3 voices, and was last updated 9 months, 3 weeks ago by
Participant.
-
AuthorPosts
-
-
April 6, 2020 at 4:54 pm #215949
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?
-
April 6, 2020 at 5:17 pm #215955
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.
-
April 6, 2020 at 5:23 pm #215961
There is a Strict Mode (https://redmondmag.com/articles/2017/12/28/understanding-powershell-strictmode.aspx). 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.
-
-
AuthorPosts
- The topic ‘Is there a “strict” case-sensitive syntax mode?’ is closed to new replies.