1. 12

  2. 2

    The examples provides a better feel of the shell. It is a shell that implements concurrent pipelines in a reasonable fashion. An example of parallel pipelines:

    FREE=$(df -h . | awk '!/Use%/{print $4}')
    ls -n |
    tee |
            # Reorder fields in DIR-like way
            awk '!/^total/ {print $6, $7, $8, $1, sprintf("%8d", $5), $9}'
            # Count number of files
            wc -l | tr -d \\n
            # Print label for number of files
            echo -n ' File(s) '
            # Tally number of bytes
            awk '{s += $5} END {printf("%d bytes\n", s)}'
            # Count number of directories
            grep -c '^d' | tr -d \\n
            # Print label for number of dirs and calculate free bytes
            echo " Dir(s) $FREE bytes free"
    }} |

    Each line inside the double braces is executed in parallel, and the output is synchronized at the end of the double braces block.

    1. 1

      That example is strange considering you can do that will a single POSIX AWK script, and without creating a new shell:


      1. 2

        Not my project. However, the intent of the example was to describe how to concurrent pipelines are composed, not so much what is accomplished. This was the simplest example I could find. You can take a look at other examples to see if others are better in this regard.

        1. 1

          The awk translation doesn’t do it in parallel? I believe the point is to use a bunch of cores. However I believe you can still do it in POSIX shell, without awk, something like this:

          ls -n |
          tee |
            func1 &
            func2 &
            func3 &
          } | 

          And then each function looks like an awk script:

          func1() {
            while read line; do
              echo $line

          Of course you can use awk too, but that isn’t central to the point.

          EDIT: I think I see now that dgsh adds its own tee so you don’t need disk files. It’s a tee that can write to parallel pipes instead, which you can’t do in pure shell AFAIK.

          So both of our examples might not be 100% correct translations. dgsh does seem like an improvement, although I wonder if it could be done with smaller changes to the shell.

      2. 1

        The sidebar doesn’t scroll, I scroll to the bottom of the page and the sidebar goes off the screen, with the selection item also off the screen…

        1. 2

          Sorry, it is not my project. I posted it since I thought it was cool, and was relevant to recent discussions on shells. Perhaps you may have better luck with reader mode?