Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bf: resolve bashism with minimal impact #1092

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

octomike
Copy link

We found a bashism in bedpostx_mgh when running trac-all and I used the tool checkbashisms in the debian devscripts package to

identify more possible issues within the scripts/ folder only:

for f in $(find . -type f) ; do head -n1 $f | grep -q '/bin/sh' && (checkbashisms $f || echo -e "\n\n$f\n\n") ; done

These are the results:

possible bashism in ./mri_motion_correct line 65 (should be >word 2>&1):
  mri_convert --in_info --read_only $1 &> $transcript_file
possible bashism in ./mri_motion_correct line 215 (should be >word 2>&1):
which which &> /dev/null
possible bashism in ./mri_motion_correct line 222 (should be >word 2>&1):
  which basename &> /dev/null
possible bashism in ./mri_motion_correct line 296 (should be >word 2>&1):
  which mri_convert &> /dev/null
possible bashism in ./mri_motion_correct line 299 (should be >word 2>&1):
  mri_convert &> /dev/null
possible bashism in ./mri_motion_correct line 323 (should be >word 2>&1):
    $p &> $transcript_file
possible bashism in ./mri_motion_correct line 347 (should be >word 2>&1):
  mri_convert $infile $outfile &> $transcript_file
possible bashism in ./mri_motion_correct line 372 (should be >word 2>&1):
    mri_convert $f $tmpdir_use/$i.mnc &> $transcript_file
possible bashism in ./mri_motion_correct line 392 (should be >word 2>&1):
      minctracc -lsq6 $tmpdir_use/$i.mnc $tmpdir_use/0.mnc $tmpdir_use/${i}_to_0.xfm &> $transcript_file
possible bashism in ./mri_motion_correct line 407 (should be >word 2>&1):
      mincresample -transformation $tmpdir_use/${i}_to_0.xfm -like $tmpdir_use/0.mnc $tmpdir_use/${i}.mnc $tmpdir_use/${i}_to_0.mnc &> $transcript_file
possible bashism in ./mri_motion_correct line 433 (should be >word 2>&1):
  mincaverage $volumes_to_average $tmpdir_use/avg.mnc &> $transcript_file
possible bashism in ./mri_motion_correct line 448 (should be >word 2>&1):
  mri_convert $tmpdir_use/avg.mnc $outfile &> $transcript_file


./mri_motion_correct


possible bashism in ./bedpostx_mgh line 129 (bash arrays, ${name[0|*|@]}):
if [ -z ${fslver[1]} ]; then fslver[1]=0; fi
possible bashism in ./bedpostx_mgh line 129 (bash arrays, H[0]):
if [ -z ${fslver[1]} ]; then fslver[1]=0; fi
possible bashism in ./bedpostx_mgh line 130 (bash arrays, ${name[0|*|@]}):
if [ -z ${fslver[2]} ]; then fslver[2]=0; fi
possible bashism in ./bedpostx_mgh line 130 (bash arrays, H[0]):
if [ -z ${fslver[2]} ]; then fslver[2]=0; fi
possible bashism in ./bedpostx_mgh line 131 (bash arrays, ${name[0|*|@]}):
if [ ${fslver[0]} -lt 6 ]; then
possible bashism in ./bedpostx_mgh line 132 (bash arrays, ${name[0|*|@]}):
    echo "Outdated FSL version (${fslver[0]}.${fslver[1]}.${fslver[2]})"


./bedpostx_mgh


possible bashism in ./map_to_base line 62 (should be 'b = a'):
if [ "$rt" == "surface" ] ; then ldir=surf ; fi


./map_to_base

The pull requests fixed the bashisms by translating the == comparison to ['s = and the bash redirection shortcut &> x to > x 2>&1 . The bedpostx_mgh script however relies on bash arrays and so I decided to switch to interpreter to bash.

No testing was done, but the changes are very trivial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant