Batch not-equal (inequality) operator

前端 未结 5 705
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-22 21:25

According to this, !==! is the not-equal string operator. Trying it, I get:

C:\\> if \"asdf\" !==! \"fdas\" echo asdf
!==! was unexpected at          


        
5条回答
  •  既然无缘
    2020-12-22 22:08

    NEQ is usually used for numbers and == is typically used for string comparison.

    I cannot find any documentation that mentions a specific and equivalent inequality operand for string comparison (in place of NEQ). The solution using IF NOT == seems the most sound approach. I can't immediately think of a circumstance in which the evaluation of operations in a batch file would cause an issue or unexpected behavior when applying the IF NOT == comparison method to strings.

    I wish I could offer insight into how the two functions behave differently on a lower level - would disassembling separate batch files (that use NEQ and IF NOT ==) offer any clues in terms of which (unofficially documented) native API calls conhost.exe is utilizing?

提交回复
热议问题