[MINC-users] space in file names

Andrew Janke a.janke at gmail.com
Fri Aug 3 01:52:04 EDT 2012


Hi Pierre

On 3 August 2012 02:32, Vladimir S. FONOV <vladimir.fonov at gmail.com> wrote:
> I think it is because mincheader is actually a shell script, and the input
> file name is substituted as $1 in a couple of places.

Vlad is indeed correct (Although it goes a bit deeper than that).

Here is a commit for mincheader to fix this:

   https://github.com/BIC-MNI/minc/commit/524ade8bc2824c72dafa564eb34f8b4ae1b7c6c8

Problem is: you are going to strike this again and again and again if
you decide to continue down the wormhole of spaces in filenames. Yes
MINC itself might be safe from spaces in filenames but I have seen
hundreds of perl/shell scripts that aren't.

My "fix" for something like this would be a symlink:

   $ ln -s 'Ubuntu One' ubu1

And from then on in, use /home/pbellec/ubu1/....



a

PS: if you do decide to stick with filenames with spaces, be sure to
hunt down every single system call in perl scripts (or &do_cmd() for
my scripts or &Spawn for MNI::Perllib) and "arrayify" them.  ie:

   &do_cmd("mincheader -clobber $filename");

becomes:

   &do_cmd("mincheader", '-clobber', $filename);

Note that this now makes it far more convoluted to do things like this:

   &do_cmd("mincheader $filename > header");

As for fixing shell scripts just put quotes around anything that might
have a filename in it!  (and cross your fingers when shell scripts
call other shell scripts....)


More information about the MINC-users mailing list