So the + at the start of the line tells you the eval/source/command substitution nesting level, the equal signs tell you the function nesting level and then you have the function name that you are in.Īdding LINENO and BASH_SOURCE are also things to consider adding to the PS4 prompt. ![]() With the OP's definitions of foo, bar and baz this gives you $ bar It is possible to use $FUNCNAME to refer to just the top element of the array, but it is clearer if you always access an arrary as an array and a scalar as a scalar. You want enough to show your function nesting, but you also want to avoid the prompt getting stupidly long if you have deep nesting (perhaps you have recursive functions). The number of characters in $_plus is a trade-off. This value is then used to select the first N characters from $_plus, which is set to a sequence of = signs. As there is one element in the array for each function currently being called this is the function depth. expands to the number of elements in the FUNCNAME array. If you are interested in the function depth then you can use the FUNCNAME array. It is also increased by command substitution. Instead, I see: + barĪm I mis-understanding what "level of indirection" means in this context, or am I just failing to reproduce said levels of indirection correctly?Īs the currently accepted answer tells you, the level is related to the nesting level which is increased by eval and sourcing. The default mapping is to distribute the queues evenly in the table, but the indirection table can be retrieved and modified at runtime using ethtool commands (-show-rxfh-indir and -set-rxfh-indir). Since bar calls foo, and foo calls baz, I had expected up to 3 levels of indirection, and therefore I expected to see something like the following (or similar) as output: + bar The indirection table of an RSS device, which resolves a queue by masked hash, is usually programmed by the driver at initialization. ![]() I wanted to reproduce this behavior in my shell, so I wrote the following code: #!/usr/bin/env bash I interpret this to mean that I will see a + symbol for each level of abstraction in my code. The first character of the expanded value is replicated multiple times, as necessary, to indicate multiple levels of indirection. Multi-dimensional arrays are also pointers, we just have a special notation for handling them. I'm reading the GNU docs, and I see the following sentence as part of the definition of PS4: Step 2 - Pointer Arithmetic and Multiple Indirection. When accessing a resource such as a database we may see the embedding of a JDBC connection string in the code as Level 0 indirection, a JNDI connection (which delegates the choice of resource to an application container) as Level 1 and some Spring construct that maps the application JNDI identifier to one of many container resources as Level 2.
0 Comments
Leave a Reply. |