What is "AARE" in AppArmor profiles? - apparmor

The man page for apparmor.d (5) uses the syntax element AARE in several places, such as in SIGNAL PEER = 'peer' '=' AARE.
The definition for AARE is this:
AARE = ?*[]{}^
See below for meanings.
My question now is: where is this "below"? I suspect AARE to maybe mean "AppArmor Regular Expression" but I simply cannot find anywhere in the AA documentation any explanation for it. Googling or DuckduckGo'ing for "apparmor AARE" simpy draws blanks except for the man page where I cannot find any explanation "below". There is a section about "Globbing" but it is totally unclear to me if the AAREs (regular expressions?) are actually refering to "globbing" -- but then globbing isn't regular expressions.
So what are AARE and what is their syntax examples, as I really don't understand the meaning of ?*[]{}^.

Based on a discussion of my original question on the AppArmor mailing list the simplified answer is: yes, AARE means "AppArmor Regular Expression". However, AAREs are nearer (shell) glob expressions, but with additional AppArmor variable expansion using the #{VAR} syntax. This is not to be confused with the glob syntax of alternatives {A,B,C} which is also supported.
While there have been discussion on man page updates I don't see them yet live in production; the proposed changes should have been related to the Globbing section.

Related

Name for ${...} constructs (for strings and arrays) in bash?

Bash allows things like ${#string} (string length) or ${array[10]} (indexing array). There's many more forms than the above, for example ones for trimming, replacing, changing case, etc.
I've been unable to find a proper name for these. I've seen sources refer to these as "string manipulations" or "array manipulations", but I can't find any official source using these names.
The manual seems to do it's best to avoid naming these constructs at all.
Does anyone know a name for these sorts of constructs? (ones of the form ${....} used to manipulate strings and arrays.) Or at least an unofficial name I could Google?
These are "parameter expansion" constructs.
See:
https://wiki.bash-hackers.org/syntax/pe (the relevant page in the bash-hackers' wiki)
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 (the relevant section of the POSIX sh specification)
https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion (the official manual)

Why is #+ used for multiline comments in the Advanced Bash-Scripting Guide

I noticed in the Advanced Bash-Scripting Guide, that multiline comments are denoted as #+ rather than simply #. E.g. here.
(there is also a #% used in that particular example, denoting something like a bullet list(?), but this is literally the only location in the document where this is used, whereas the #+ syntax is used extensively)
I was wondering if this is some sort of convention, or if there is a particular reason for it other than the fact it just looks nice.
I note that it specifically seems to denote lines that are meant to be a continuation on a single line, rather than multi-line comments in general, so I'm wondering if it was simply done internally for parsing / documentation generation.
Has anyone else encountered this out in the wild before? Does anyone actually use this style?

What does "$(#:H)" do in MakeFile?

I was speaking with one of my fellow interns at lunch today who is working almost exclusively in Makefile this summer, and he mentioned that he has no idea what $(#:H) means or does. My google-fu is failing me, as I cannot find it anywhere on the web, and was hoping you guys could help me out.
Assuming this is GNU make then that's just the expansion of the (oddly named) #:H variable. Which isn't a default variable (and isn't a variable that can be set with the normal assignment syntax) and would be an odd choice for a variable name to begin with as it is very close to real variable expansions.
It is much more likely that this is referring to BSD make where :H is a variable modifier which (excerpt from the man page):
:H
Replaces each word in the variable with everything but the last component.

What is the formal term for the "#{}" token in Ruby syntax?

The Background
I recently posted an answer where I variously referred to #{} as a literal, an operator, and (in one draft) a "literal constructor." The squishiness of this definition didn't really affect the quality of the answer, since the question was more about what it does and how to find language references for it, but I'm unhappy with being unable to point to a canonical definition of exactly what to call this element of Ruby syntax.
The Ruby manual mentions this syntax element in the section on expression substitution, but doesn't really define the term for the syntax itself. Almost every reference to this language element says it's used for string interpolation, but doesn't define what it is.
Wikipedia Definitions
Here are some Wikipedia definitions that imply this construct is (strictly speaking) neither a literal nor an operator.
Literal (computer programming)
Operator (programming)
The Questions
Does anyone know what the proper term is for this language element? If so, can you please point me to a formal definition?
Ruby's parser calls #{} the "embexpr" operator. That's EMBedded EXPRession, naturally.
I would definitely call it neither a literal (that's more for, e.g. string literals or number literals themselves, but not parts thereof) nor an operator; those are solely for e.g. binary or unary (infix) operators.
I would either just refer to it without a noun (i.e. for string interpolation), or perhaps call those characters the string interpolation sequence or escape.
TL;DR
Originally, I'd hypothesized:
Embedded expression seems the most likely definition for this token, based on hints in the source code.
This turned out to be true, and has been officially validated by the Ruby 2.x documentation. Based on the updates to the Ripper documentation since this answer was originally written, it seems the parser token is formally defined as string_embexpr and the symbol itself is called an "embedded expression." See the Update for Ruby 2.x section at the bottom of this answer for detailed corroboration.
The remainder of the answer is still relevant, especially for older Rubies such as Ruby 1.9.3, and the methodology used to develop the original answer remains interesting. I am therefore updating the answer, but leaving the bulk of the original post as-is for historical purposes, even though the current answer could now be shorter.
Pre-2.x Answer Based on Ruby 1.9.3 Source Code
Related Answer
This answer calls attention to the Ruby source, which makes numerous references to embexpr throughout the code base. #Phlip suggests that this variable is an abbreviation for "EMBedded EXPRession." This seems like a reasonable interpretation, but neither the ruby-1.9.3-p194 source nor Google (as of this writing) explicitly references the term embedded expression in association with embexpr in any context, Ruby-related or not.
Additional Research
A scan of the Ruby 1.9.3-p194 source code with:
ack-grep -cil --type-add=YACC=.y embexpr .rvm/src/ruby-1.9.3-p194 |
sort -rnk2 -t: |
sed 's!^.*/!!'
reveals 9 files and 33 lines with the term embexpr:
test_scanner_events.rb:12
test_parser_events.rb:7
eventids2.c:5
eventids1.c:3
eventids2table.c:2
parse.y:1
parse.c:1
ripper.y:1
ripper.c:1
Of particular interest is the inclusion of string_embexpr on line 4,176 of the parse.y and ripper.y bison files. Likewise, TestRipper::ParserEvents#test_string_embexpr contains two references to parsing #{} on lines 899 and 902 of test_parser_events.rb.
The scanner, exercised in test_scanner_events.rb, is also noteworthy. This file defines tests in #test_embexpr_beg and #test_embexpr_end that scan for the token #{expr} inside various string expressions. The tests reference both embexpr and expr, raising the likelihood that "embedded expression" is indeed a sensible name for the thing.
Update for Ruby 2.x
Since this post was originally written, the documentation for the standard library's Ripper class has been updated to formally identify the token. The usage section provides "Hello, #{world}!" as an example, and says in part:
Within our :string_literal you’ll notice two #tstring_content, this is the literal part for Hello, and !. Between the two #tstring_content statements is a :string_embexpr, where embexpr is an embedded expression.
This Block post suggests, it is called an 'idiom':
http://kconrails.com/2010/12/08/ruby-string-interpolation/
The Wikipedia Article doesn't seem to contradict that:
http://en.wikipedia.org/wiki/Programming_idiom
#{} It's called placeholder and is used to reference variables with a string.
puts "My name is #{my_name}"

Mathematica "\<...\>" syntax

In an answer to another SO question, passing mention was made to a Mathematica string escape syntax that looks like this: "\<...\>". Apparently, this syntax is useful for dealing with embedded newlines in strings. I've tried searching for documentation using various terms in the Mathematica help browser (and Google), but to no avail. Where can I find documentation on this syntax?
Answer Summary
#Mark points out that the construct is documented in Section 2.8.6 of the V5 Mathematica book. It is also mentioned in Section 2.8.7 of the V5.2 Mathematica Book. In both of those locations, the documentation states that Mathematica ignores line breaks and following tabs in strings -- unless they are enclosed between \< and \> in which case the line breaks (but not tabs) are retained.
In the corresponding section of the V6 documentation, it states that line breaks are retained in strings. Therefore, it appears that the escape syntax is no longer needed starting in V6 -- and is therefore no longer documented.
Note that many notebooks still use this syntax internally, even in V8. #Alexey points out that the cell expressions for strings that contain line breaks still use the syntax.
It's mentioned briefly in section 2.8.6 of the most recent edition of The Mathematica Book. Of course, that's for V5 of Mathematica. In fact, I just tried the following in both V5.2 and V6.0.3:
"Hi
There"
The results were quite different. In particular, V5.2 returned a single line, with no newline character. V6.0.3 returned two lines with the newline character formatted as expected. Strings were improved considerably in V6, so perhaps the `"\<...\>" construct is no longer required.
And perhaps I've been using Mathematica for way too long. :)

Resources