I have the following code in a file that is sourced by both zsh and bash.if test $SHELLNAME = zsh ; then    lss() { l -l ${1:-.}/*(s,S,t); }    laf() { l ${1:-.}/.*(.); }    lad() { l -d ${1:-.}/.*(/); }    lsw() { l -ld ${1:-.}/.*(R,W,X.^ND/); }fiSHELLNAME is zsh if the shell is zsh and bash if the shell is bash.Each of the above functions contains code that works with zsh, but not bash.When I source this file, I receive the following errors.bash: <filename>: line 67: syntax error near unexpected token `('bash: <filename>: line 67: `     lss() { l -l ${1:-.}/*(s,S,t); }'At the moment, I am using eval to bypass bash's syntax checking.if test $SHELLNAME = zsh ; then    # Using eval makes sure bash can't try to syntax-check these functions.    eval 'lss() { l -l ${1:-.}/*(s,S,t); }'    eval 'laf() { l ${1:-.}/.*(.); }'    eval 'lad() { l -d ${1:-.}/.*(/); }'    eval 'lsw() { l -ld ${1:-.}/.*(R,W,X.^ND/); }'fiIs there a better solution to this problem? (perhaps one that doesn't use eval)
How do I stop bash from syntax checking sourced files?
bash;zsh
You only need one eval.[ -n $ZSH_VERSION ] &&  eval '    lss() l -l ${1:-.}/*(s,S,t)    laf() l ${1:-.}/.*(.)    lad() l -d ${1:-.}/.*(/)    lsw() l -ld ${1:-.}/.*(R,W,X.^ND/)  '(note that zsh contrary to bash does support the Bourne function syntax)Or:[ -n $ZSH_VERSION ] && . /dev/fd/3 3<< '# End of zsh specific section'  lss() l -l ${1:-.}/*(s,S,t)  laf() l ${1:-.}/.*(.)  lad() l -d ${1:-.}/.*(/)  lsw() l -ld ${1:-.}/.*(R,W,X.^ND/)# End of zsh specific sectionBut I'd tend to agree with slm that having the zsh specific syntax in a separate file only sourced by zsh would make sense.