An answer to another question suggests using the following piece of code in a script:
case ":$PATH:" in
*:$HOME/mydir:*) echo it is in the path;;
*) echo not there ;;
esac
The purpose of this code is to check whether $HOME/mydir
is in $PATH
, but the examples in this and this suggest exact 'matching' rather than 'contains'.
How is 'case' operating here? Thanks.