Monday, January 5, 2009

Process substitution is cool !

I've finally found some time to work on ctioga again ! My main problem there is that I keep adding new features without ever bothering to document them... One of my main concerns is therefore to find out about the list of command-line switches that are not documented in the manual page. I've just written a neat shell one-liner that precisely does that:

diff <(man -a -l $HOME/SciYAG/ctioga/doc/ctioga.1 | \
  egrep -o -- '--[a-z0-9-]+' | sort | uniq) \
  <(ctioga --help | egrep -o -- '--[][a-z0-9-]+' | \
  sort | uniq) | colordiff | less -R

(of course, I broke it into lines for clarity). It is based on process substitution, a shell trick that lets you use the output/input of a shell command exactly as a file on command line. Neat ! The trouble is, replacing the colordiff... part by | egrep '^>' | wc tells me there are 65 undocumented features... Lots of work in perspective, and I'm not sure I'll do it all before the 1.9 release...

1 comment:

Justin A said...

Indeed.. I use diff <(prog file1) <(prog file2) all the time.

zsh also has a =() which uses real temporary files instead of pipes.