Open andrewjanke opened 9 years ago
Looking at the mincreshape code, it seems to do something reasonable here, which is pass the argument string to strtol(). My only concern is that it uses strtol() with base=0, so it interprets a leading '0' as starting an octal number. So 0001 should actually work, but 0008 will fail somewhat mysteriously.
The easy thing would be to disallow octal and hex here and hand an explicit base=10 to strtol(), as I seriously doubt anyone relies on passing octal values. I'm less sure about hex values, but they also seem pretty unlikely.
I'm for it! (and am with you on the unlikely use of octal and hex).
Thanks for hunting this one down, it took me long enough to figure what was going wrong with my nipype script that was calling a perl script that was calling shell that was.... At that point I found the strange error was due to mincreshape I decided it was time to stop digging.
A quick glance shows that ParseArgv.c does something similar with its integer arguments.
Just to be safe, I might implement a quick solution that recognizes a leading 0x/0X as indicating hex, but treats everything else as decimal. I think that would be the most conservative fix - I can't imagine anyone is relying on passing octal arguments, but I can't completely rule out hex in some contexts.
Works for me. The leading 0x is consistent with a number of other command line tools and scripting languages.
Thanks
OK, I checked in these changes in the develop branch. Check it out when you have a spare tic.
Looks good to me.
Thanks
a
On 3 June 2015 at 00:09, Robert D Vincent notifications@github.com wrote:
OK, I checked in these changes in the develop branch. Check it out when you have a spare tic.
— Reply to this email directly or view it on GitHub https://github.com/BIC-MNI/minc-tools/issues/24#issuecomment-107967976.
mincreshape (and a few other tools) can be a bit picky about their input arguments, as an example:
$ mincreshape -dimrange zspace=0001,0 ...
Will fail as it doesn't understand 0001 as 1. This can be a pain when calling mincreshape and friends from within scripts. What's the consensus on what the behaviour should be for this?