Sponsored Content
Top Forums UNIX for Beginners Questions & Answers When should i use [] or [[]]? Post 302980460 by Don Cragun on Sunday 28th of August 2016 11:48:23 AM
Old 08-28-2016
Quote:
Originally Posted by jim mcnamara
FWIW - this shows [[ as part of the POSIX shell
IBM Knowledge Center Error

Because Shell Command Language
in the "Case Conditional Construct" section shows the function of [[ ]]

So it appears any POSIX conforming shell will support [[
The POSIX-conforming shell on AIX is the Korn shell and the Korn shell includes the keyword [[. So, I assume that you can use [[ in AIX's sh which is based on or linked to ksh.

The text from the POSIX shell command language you pointed to above says:
Quote:
The following words may be recognized as reserved words on some implementations (when none of the characters are quoted), causing unspecified results:
[[ ]] function select
So, the POSIX standard allows [[ expression ]] to be supported by conforming shells, but says absolutely nothing about what [[ expression ]] does in a shell script.

The next revision of the POSIX standards and the Single UNIX Specification (which are likely to be balloted by IEEE, ISO/IEC, and The Open Group in about 3-7 years) is, in my personal opinion, likely to add defined behavior for the keywords [[ and ]] and many, or all, of common set of expressions that are available in both recent bash and ksh93 shells with [[ expression ]]. You can see a very lengthy record of a small subset of the discussion on this topic in The Austin Group's bug report on this topic: Bug #375: Extend test/[...] conditionals: ==, <, >, -nt, -ot, -ef. Note that this bug report is still open AND that the initially suggested Desired Action will NOT make it into the standard.

Last edited by Don Cragun; 08-28-2016 at 01:21 PM.. Reason: Add link to POSIX Bug #375.
 
All times are GMT -4. The time now is 10:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy