[MINC-users] Of clobbering

Andrew Janke a.janke at gmail.com
Mon Mar 18 00:31:16 EDT 2013


Hi Alex,

> I just realized that when clobbering an output file that is a symbolic
> link, several (all?) minc tools will (try to) clobber the target of the
> link instead of the link itself.
>
> I tested this with a few tools (mincaverage, mincmath, mincmorph, minccalc,
> mincresample) and all of them behave this way.

Regardless of if this is a problem or not this behaviour comes about
because of this:

   https://github.com/BIC-MNI/minc/blob/master/libsrc/hdf_convenience.c#L2299

There are ways in HDF of checking if the target is a link.

> IMHO this is actually _really_ bad behaviour; so I was wondering what
> others thought of this, and if this was done by design?

I think you'll find that it was done this way by design, while it's
not the most intuitive thing to do in some cases its (to me) the best
approach to take for all cases. I can think of quite a few scripts of
mine that rely upon this behaviour...

I can also think of a few scripts that don't behave like the library
and instead clobber the link and replace it with a file. The typically
happens like this:

   if( -e $outfile && $clobber){
      system('rm -f $outfile);
      }

   system('stuff $infile $outfile');

a


More information about the MINC-users mailing list