Skip to main content
20 events
when toggle format what by license comment
Jan 27 at 19:40 history edited Alexis Wilke CC BY-SA 4.0
Fixed the "oper and" (removed the spaces) and added a few more `...`
Jan 5, 2021 at 15:54 comment added Alexis Wilke @GordonDavisson, indeed. I made an edit accordingly.
Jan 5, 2021 at 15:54 history edited Alexis Wilke CC BY-SA 4.0
As per comment, fixed the info regard the "search" for ']'
Jan 5, 2021 at 5:12 comment added Gordon Davisson Correction: [ does not parse parameters until it finds a parameter ]; instead, it checks that its last argument is "]", and then ignores it while parsing the rest of its arguments as a test expression. This means that "]" can occur in the middle of the expression as well as the end. For example, if [ "$foo" = ] ]; then will test whether the variable foo is set to "]" (as will if [ ] = "$foo" ]; then).
Feb 10, 2018 at 21:49 comment added Alexis Wilke @Alexander, I applied a correction. Thank you for pointing that out.
Feb 10, 2018 at 21:48 history edited Alexis Wilke CC BY-SA 3.0
Fixed the () "no effect" statement with the exit code (thanks to Alexander.)
Feb 10, 2018 at 8:23 comment added Alexander (exit 1) has an effect outside of the parentheses.
Aug 28, 2016 at 4:50 comment added jlliagre @Random832 Of course, you are free to disagree and file a bug. Here is the link austingroupbugs.net/main_page.php . Keep us informed if you do !
Aug 28, 2016 at 4:50 comment added jlliagre @Random832 I know quite well that paragraph ( see unix.stackexchange.com/questions/38808/why-is-cd-not-a-program/… ) but IMHO there is nothing in this case Solaris is violating. The test utility is definitely provided as a standalone executable. Nowhere is written it requires its variant to be that way, and the fact it doesn't conform with the first and second guidelines stated here pubs.opengroup.org/onlinepubs/9699919799/basedefs/… likely doesn't help supporting the idea.
Aug 28, 2016 at 4:11 comment added Random832 @jlliagre See the last paragraph here. If that's true it's probably a bug in whatever test suite was used to certify its compliance. (Note: Yes, it is permitted for it to exist as a symlink or hardlink and not a separate and distinct file, but it sounded like you were saying it's not required to exist, and doesn't exist, as any kind of file at all - there's no language in the standard treating [ differently from test for the purpose of this requirement)
Aug 28, 2016 at 4:00 comment added jlliagre @Random832 I get your point about the GNU rationale to avoid unexpected arg0 behavior but about POSIX requirements, I wouldn't be so affirmative. While the test command is obviously required to exist as a standalone file based command by the standard, nothing in it states its [ variant need to be implemented that way too. For example, Solaris 11 doesn't provide any [ executable but is nevertheless fully compliant with the POSIX standards
Aug 28, 2016 at 2:48 comment added Random832 @jlliagre It does require it to exist as a file (hell, it requires cd to exist as a file); the purpose of the portable filename character set doesn't preclude the standard requiring a specific file with a specific name containing a character set outside it. Anyway, modern systems tend to lean away from the "single binary handling different behaviors depending on argv[0] concept - There's a rationale for why it's a considered bad (and why gnu coreutils doesn't do it, not only for [/test, but also ls/dir/vdir) EDIT: gnu.org/prep/standards/html_node/User-Interfaces.html
Aug 27, 2016 at 23:20 comment added jlliagre @Random832 The difference is [ needs to look for a closing ] while test does not. Of course a purposely designed single binary can handle both behaviors but my understanding is POSIX doesn't require [ to exist as a file. Its name is not even in the portable file name character set.
Aug 27, 2016 at 19:50 comment added ilkkachu Somehow, I find it amusing that they bother to create two separate binaries, which both have just exactly what they need, instead of just combining them and adding a couple of conditionals. Though actually strings /usr/bin/test shows it has the help text too, so I don't know what to say.
Aug 27, 2016 at 19:20 comment added Random832 They're the same size on OSX. I think the difference on GNU is that [ supports --help and --version, so the text for those options is included, and test does not. command [ --help|wc -c shows the help text is 3 kb.
Aug 27, 2016 at 19:19 history edited Alexis Wilke CC BY-SA 3.0
Fixed the info about the `[ expr ]`
Aug 27, 2016 at 19:17 comment added Alexis Wilke @Random832 Ah... Interest, not only [ is not a symbolic link, it's not the same size as test! So it is its own beast altogether.
Aug 27, 2016 at 19:16 comment added Random832 The external binary for [ is not a symbolic link to test on most modern systems.
Aug 27, 2016 at 19:12 comment added ilkkachu Though test and [ are of course builtin commands in Bash, but it's likely that an external binary exists too.
Aug 27, 2016 at 19:06 history answered Alexis Wilke CC BY-SA 3.0