{"id":5461,"date":"2008-09-22T20:44:00","date_gmt":"2008-09-22T20:44:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2008\/09\/22\/decision-input-requested-eq-with-characters\/"},"modified":"2019-02-18T13:13:00","modified_gmt":"2019-02-18T20:13:00","slug":"decision-input-requested-eq-with-characters","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/decision-input-requested-eq-with-characters\/","title":{"rendered":"Decision Input Requested:  -EQ with Characters"},"content":{"rendered":"<p>We are struggling with whether or not to make a change in our comparison operators and would like feedback from the community.<\/p>\n<p>Here is the documentation about comparision&nbsp;operators:&nbsp;<\/p>\n<blockquote>\n<p>&nbsp;All comparison operators are case-insensitive by default. To make a comparison operator<br \/>&nbsp;case-sensitive, precede the operator name with a &#8220;c&#8221;. For example, the case-sensitive<br \/>&nbsp;version of &#8220;-eq&#8221; is &#8220;-ceq&#8221;. To make the case-insensitivity explicit, precede the operator<br \/>&nbsp;with an &#8220;i&#8221;, for example, the explicitly case-insensitive version of &#8220;-eq&#8221; is &#8220;ieq&#8221;.<\/p>\n<\/blockquote>\n<p>Here are examples of the current -EQ semantics:<\/p>\n<p>PS&gt; &#8220;a&#8221; -eq &#8220;A&#8221;<br \/>True<br \/>PS&gt; [char]&#8217;a&#8217; -eq &#8216;a&#8217;<br \/>True<br \/>PS&gt; 2 -eq 2<br \/>True<\/p>\n<p>Notice that&nbsp;-EQ works with Strings, Chars, and INTs&nbsp;(and lots of other things).&nbsp; <\/p>\n<p>Now&nbsp;for the headache:&nbsp;<\/p>\n<p>PS&gt; [char]&#8217;a&#8217; -eq &#8216;A&#8217;<br \/><strong>False<br \/><\/strong>PS&gt; [char]&#8217;a&#8217; -ieq &#8216;A&#8217;<br \/><strong>False<\/strong><\/p>\n<p>&lt;Update:&nbsp; Notice that you get FALSE whether you&nbsp;use -eq (EQUALS) or -ieq (CASE INSENSITIVE EQUALS)&nbsp;&gt;<\/p>\n<p>What is happening here is that CHARs are being treated like INTs and not like STRINGs.&nbsp; In our bug triage, we the feeling was that this was clearly a bug and should be fixed but someone pointed out that this if a script made use of these semantics, fixing the bug would break that script.&nbsp; There are 2 things to say about that:<\/p>\n<ol>\n<li>Whenever you fix a bug, you run the risk of breaking a script.<\/li>\n<li>We are committed to making V2 useful and compatible with V1.<\/li>\n<\/ol>\n<p>So you see the rub.&nbsp; We&#8217;d like your help and input on this decision.&nbsp; I&#8217;m fine getting feedback on the&nbsp;&#8220;general principles&#8221; of the&nbsp;issue &#8211; understanding how you think about these issues is very helpful to us.&nbsp; That said, I&#8217;m also keenly interested in comments about the specifics of this problem. If we make THIS change, do you think it will break scripts?&nbsp; If so, should we fix this anyway or not?<\/p>\n<p>We struggled with this decision and had lots of back and forth on this and could go either way.&nbsp; In the end, we decided that&nbsp;a key stackholder wasn&#8217;t in the room:&nbsp; YOU.&nbsp;<\/p>\n<p>Please opine.<\/p>\n<p>&lt;UPDATE:&nbsp; BTW 10,000 apologizes for this situation in the first place.&nbsp; I should have started with that.&gt;<\/p>\n<p>Jeffrey Snover [MSFT]<br \/>Windows Management Partner Architect<br \/>Visit the Windows PowerShell Team blog at:&nbsp;&nbsp;&nbsp; <a href=\"http:\/\/blogs.msdn.com\/PowerShell\">http:\/\/blogs.msdn.com\/PowerShell<\/a><br \/>Visit the Windows PowerShell ScriptCenter at:&nbsp; <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\">http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We are struggling with whether or not to make a change in our comparison operators and would like feedback from the community. Here is the documentation about comparision&nbsp;operators:&nbsp; &nbsp;All comparison operators are case-insensitive by default. To make a comparison operator&nbsp;case-sensitive, precede the operator name with a &#8220;c&#8221;. For example, the case-sensitive&nbsp;version of &#8220;-eq&#8221; is &#8220;-ceq&#8221;. [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5461","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>We are struggling with whether or not to make a change in our comparison operators and would like feedback from the community. Here is the documentation about comparision&nbsp;operators:&nbsp; &nbsp;All comparison operators are case-insensitive by default. To make a comparison operator&nbsp;case-sensitive, precede the operator name with a &#8220;c&#8221;. For example, the case-sensitive&nbsp;version of &#8220;-eq&#8221; is &#8220;-ceq&#8221;. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/5461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=5461"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/5461\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=5461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=5461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=5461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}