[Semibug] Setting environment variables « { [ ( brackets) ] } »

BCLUG admin at bclug.ca
Fri Aug 11 00:36:26 EDT 2023


Steve Litt wrote on 2023-08-10 16:41:

> You said brackets but used parentheses. Did you mean to use square
> brackets in the code?

I used round brackets (aka parentheses).

Square brackets would not have worked for a sub-shell - round brackets 
(aka parentheses) are required.


For anyone curious about shell semantics and the types of brackets:

Brace brackets group items into a comma-separated list which the shell 
will iterate through:

 > $ touch file.{a,b,c,d,e,f}
 > $ ls file*
 > file.a  file.b  file.c  file.d  file.e  file.f


Square brackets are for selecting elements from sets, i.e. [abc] allows 
any of "a", "b", or "c" to match (like regular expressions):

 > $ ls file.[abc]
 > file.a  file.b  file.c

Files file.d, file.e, and file.f are excluded from `ls` due to being 
absent from [abc] set.



The 3 forms of brackets ( (round), [square], {brace} ) are used to 
bracket (enclose) content. «Chevron brackets» are fairly rare this side 
of the pond (Québec excluded).

 > https://en.wikipedia.org/wiki/Bracket



More information about the Semibug mailing list