2014-09-16 6 views
0

Xcode는 쉘 스크립트를 색칠하는 것을 정말로 망칠 것 같습니다. 예를 들어, 다음 스 니펫을 Xcode에 복사하면 전체 청크의 대부분이 빨간색으로 표시됩니다.Xcode에서 쉘 스크립트로 색상이 잘못 되었습니까?

### Creation of the GM template by averaging all (or following the template_list for) the GM_nl_0 and GM_xflipped_nl_0 images 
cat <<stage_tpl3 > fslvbm2c 
#!/bin/sh 
if [ -f ../template_list ] ; then 
    template_list=\`cat ../template_list\` 
    template_list=\`\$FSLDIR/bin/remove_ext \$template_list\` 
else 
    template_list=\`echo *_struc.* | sed 's/_struc\./\./g'\` 
    template_list=\`\$FSLDIR/bin/remove_ext \$template_list | sort -u\` 
    echo "WARNING - study-specific template will be created from ALL input data - may not be group-size matched!!!" 
fi 
for g in \$template_list ; do 
    mergelist="\$mergelist \${g}_struc_GM_to_T" 
done 
\$FSLDIR/bin/fslmerge -t template_4D_GM \$mergelist 
\$FSLDIR/bin/fslmaths template_4D_GM -Tmean template_GM 
\$FSLDIR/bin/fslswapdim template_GM -x y z template_GM_flipped 
\$FSLDIR/bin/fslmaths template_GM -add template_GM_flipped -div 2 template_GM_init 
stage_tpl3 
chmod +x fslvbm2c 
fslvbm2c_id=`fsl_sub -j $fslvbm2b_id -T 15 -N fslvbm2c ./fslvbm2c` 
echo Creating first-pass template: ID=$fslvbm2c_id 

### Estimation of the registration parameters of GM to grey matter standard template 
/bin/rm -f fslvbm2d 
T=template_GM_init 
for g in `$FSLDIR/bin/imglob *_struc.*` ; do 
    echo "${FSLDIR}/bin/fsl_reg ${g}_GM $T ${g}_GM_to_T_init $REG -fnirt \"--config=GM_2_MNI152GM_2mm.cnf\"" >> fslvbm2d 
done 
chmod a+x fslvbm2d 
fslvbm2d_id=`$FSLDIR/bin/fsl_sub -j $fslvbm2c_id -T $HOWLONG -N fslvbm2d -t ./fslvbm2d` 
echo Running registration to first-pass template: ID=$fslvbm2d_id 

### Creation of the GM template by averaging all (or following the template_list for) the GM_nl_0 and GM_xflipped_nl_0 images 
cat <<stage_tpl4 > fslvbm2e 
#!/bin/sh 
if [ -f ../template_list ] ; then 
    template_list=\`cat ../template_list\` 
    template_list=\`\$FSLDIR/bin/remove_ext \$template_list\` 
else 
    template_list=\`echo *_struc.* | sed 's/_struc\./\./g'\` 
    template_list=\`\$FSLDIR/bin/remove_ext \$template_list | sort -u\` 
    echo "WARNING - study-specific template will be created from ALL input data - may not be group-size matched!!!" 
fi 
for g in \$template_list ; do 
    mergelist="\$mergelist \${g}_struc_GM_to_T_init" 
done 
\$FSLDIR/bin/fslmerge -t template_4D_GM \$mergelist 
\$FSLDIR/bin/fslmaths template_4D_GM -Tmean template_GM 
\$FSLDIR/bin/fslswapdim template_GM -x y z template_GM_flipped 
\$FSLDIR/bin/fslmaths template_GM -add template_GM_flipped -div 2 template_GM 
stage_tpl4 
chmod +x fslvbm2e 
fslvbm2e_id=`fsl_sub -j $fslvbm2d_id -T 15 -N fslvbm2e ./fslvbm2e` 
echo Creating second-pass template: ID=$fslvbm2e_id 

이렇게 표시됩니다.

enter image description here

내가 엑스 코드 착색 문제를 해결할 수있게된다 방법이 있나요?

+0

Xcode의 편집기 및 구문 강조 기능은 Objectie-C 및 Swift와 매우 밀접하게 연결되어 있습니다. 쉘 스크립트 및 다른 언어 (예 : TextMate 또는 Sublime Text)에 대해 다른 텍스트 편집기를 사용해 볼 수 있습니다. –

+0

@ZevEisenberg 의견을 보내 주셔서 감사합니다. 숭고한 끔찍한 괴물입니다! –

답변

2

혼란스러운 Xcode 구문 강조는 특히 heredocs (<<EOF)와 이스케이프 처리 된 백틱 (\`)의 조합입니다.

cat <<'stage_tpl3' > fslvbm2c 
... 
template_list=`cat ../template_list` 
... 
stage_tpl3 
:

너무 오래 heredocs에는 치환 된 내용이 없기 때문에,이 그대로 그것을 해결하는 방법은 없지만, 당신은 첫 번째 장소에서 탈출 역 따옴표에 대한 요구 사항을 제거하기 위해 인용 히어 닥을 사용할 수 있습니다

heredoc의 종료 레이블이 따옴표로 묶인 경우 heredoc 내의 대체가 비활성화됩니다. 그것은 똑같은 방식으로 작동하며, Xcode는 더 우아하게 그것을 강조 할 수 있습니다. (보너스로, 그것을 읽고 방식으로 모든 백 슬래시없이 스크립트를 작성하는 것이 더 쉽다!)를 같이


를 제외하고, 항상 heredocs의 라벨 "EOF"를 사용하는 기존의 있습니다. 일부 편집자는 구문 강조를 위해 특수한 경우가 있습니다. 또한 문서에 특정한 것보다 쉽게 ​​발견 할 수 있습니다.

+0

\\ ... ... \ 대신'$ (...)'도 파서를 도와줍니다. – jm666

관련 문제