[FFmpeg-devel] [PATCH] doc&tools: Add murge script, for analyzing 3 way conflicts.

Nicolas George george at nsup.org
Wed Aug 17 20:34:07 EEST 2016

Le primidi 1er fructidor, an CCXXIV, Clement Boesch a écrit :
> maybe these files should be in /tmp
> i'd also suggest
> TMPFILES="murge.theirs murge.common murge.ours murge.X"
> trap 'rm -f -- $TMPFILES' EXIT
> (stolen from configure)

Temporary files are annoying and tricky (and configure does not clean up
when it is interrupted).

I suggest to require a more advanced shell (bash or zsh; since this tool is
meant for developers it is acceptable) and use process substitution:

diff <(grep ...) <(grep ...)

It starts both grep processes just like "grep | diff", but then, instead of
connecting the other end of the pipe to diff's standard input, it gives it
the corresponding file name as /dev/fd/42.

If temp files are really necessary because the command does not work with
pipes, then zsh's process substitution can serve:

diff =(grep ...) =(grep ...)

It does the same as <(grep) but with a temp file instead of a pipe; zsh does
all the cleanup for us.

Last of all, if temp files are necessary because the output needs to be
processed several times, zsh's process substitution can still be abused:

function do_the_work {
  grep > $1
  grep > $2
  grep > $3
  diff $1 $2
  diff $2 $3
do_the_work =(:) =(:) =(:)

The strange smileys are just process substitution with a dummy command.
Therefore, it starts the function with three temp files. They are all empty,
because the dummy command does not produce output, but they can then be used
in the function.


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160817/a37120d9/attachment.sig>

More information about the ffmpeg-devel mailing list