Annotated links: Episode 39 of Hands-on SAP dev with qmacro
This is a searchable description of the content of a live stream recording, specifically “Ep.39 – Looking at process substitution” in the “Hands-on SAP dev with qmacro” series. There are links directly to specific highlights in the video recording. For links to annotations of other episodes, please see the “Catch the replays” section of the series blog post.
Brief synopsis: This is an impromptu live stream where we look briefly at process substitution in the shell, a powerful construct useful for command line processing.
00:10 Explaining the purpose of this impromptu episode on a Sunday morning, to test out a reconfiguration of my OBS streaming software – to encode and stream a smaller base canvas in order to try and reduce the load on the machine (I noticed an increase load since I started to use a 4K monitor).
02:30 Looking at what we did at the end of the previous episode (Ep38) – comparing two different JSON representations of the Core Schema Notation (CSN) for the Business Partner API. In the previous episode we created intermediate files before firing up
vimdiff. This works but is a little pedestrian and we have to remember to clean up those files afterwards.
04:50 I discovered the concept of Process Substitution a few weeks ago, which is a shell feature. Looking at the Wikipedia entry for Process Substitution we see a nice succinct and helpful definition, telling us that it “… allows the input or output of a command to appear as a file”. This will enable us to use
vimdiff, which expects to work on files, with the STDOUT of sub processes (rather than having to create intermediate files). Amazing!
06:20 Reminding ourselves of what we did previously:
jq < ./API_BUSINESS_PARTNER.json > tut.json jq < ./conv/API_BUSINESS_PARTNER.json > new.json # the file we created with edmx2csn vimdiff tut.json new.json rm tut.json new.json
07:35 With process substitution in Bash, we have the
<() construct for input; there’s also
<() for output, which we don’t use here. This is all we have to do:
vimdiff <(jq < ./API_BUSINESS.PARTNER.json) <(jq < ./conv/API_BUSINESS_PARTNER.json)
No pre-step to create files, and no cleanup of those files afterwards. Beautiful.
08:30 Noting that the “file” names (e.g.
/dev/fd/63) in Vim are non-writeable “file descriptors” which you’ll learn more about when you look into how process substitution works.
09:30 We see that process substitution first appeared in the Korn shell in 1988. The Korn shell was written by David Korn, who I’ve seen modelling a tshirt with a wonderful statement on the front that I think should make it onto a #HandsOnSAPDev tshirt, don’t you? 🙂