Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 2
    [ is a program. You will find it in /bin/[. Some shells may optimise by handling it internally instead of calling the actual executable. Commented Mar 26, 2022 at 12:36
  • @OrangeDog There is no guarantee that the shell’s built-in [ will behave the same way as the external command in /bin/[. Indeed, my Debian 10 system’s man page for [ says: “Please refer to your shell's documentation for details about the options it supports.” Commented Mar 26, 2022 at 12:55
  • @BrianDrake they are guaranteed to behave in exactly the same way. Especially if the docs for one refer you to the other. Commented Mar 26, 2022 at 19:16
  • @OrangeDog Although an identical behavior is expected in most cases, there is not guarantee that both always behave the same way. For example errors message might vary. Commented Mar 26, 2022 at 21:51
  • 1
    @OrangeDog The [ man page I cited gives a complete description of the external [ command, before stating that the shell may have its own version and referring the user to the shell’s documentation. The bash man page also has a complete description of bash’s implementation. A cursory look suggests that there are at least two differences: only bash’s implementation supports -a as a synonym for -e, and only the external command supports -l for the length of a string. Commented Mar 27, 2022 at 6:41