Using -e in the echo command seems to me pure obfuscation, since it could have been written:
p() { [ $# -eq 0 ] && echo || (shift; p " $@ ") | while read r ; do echo $1 $r echo $r done }
In other words, "for each set in the set of degrees of all but the first argument (shift; p " $@ ") , print both values ββset with and without the first argument."
The bash function works by setting up a chain of subshells, each of which reads the next, something like this, where each box is a subshell and below it, I showed its output when it reads each line (I used "" to do "nothing" visible. => means "call"; <- means "read".)
+---------+ +-------+ +-------+ +-------+ | p 1 2 3 | ==> | p 2 3 | ==> | p 3 | ==> | p | +---------+ +-------+ +-------+ +-------+ 1 2 3 "" <--+-- 2 3 "" <---+-- 3 "" <-----+-- "" 2 3 "" <-/ / / 1 3 "" <--+-- 3 "" <-/ / 3 "" <-/ / 1 2 "" <--+-- 2 "" <---+-- "" <-/ 2 "" <-/ / 1 "" <--+-- "" <-/ "" <-/
source share