Junxiao Shi | 439d972 | 2015-03-20 15:08:44 -0700 | [diff] [blame] | 1 | has() { |
Davide Pesavento | 956ac31 | 2016-09-20 19:11:30 +0200 | [diff] [blame] | 2 | local saved_xtrace |
3 | [[ $- == *x* ]] && saved_xtrace=-x || saved_xtrace=+x | ||||
4 | set +x | ||||
5 | |||||
Junxiao Shi | 439d972 | 2015-03-20 15:08:44 -0700 | [diff] [blame] | 6 | local p=$1 |
7 | shift | ||||
Davide Pesavento | 956ac31 | 2016-09-20 19:11:30 +0200 | [diff] [blame] | 8 | local i ret=1 |
9 | for i in "$@"; do | ||||
10 | if [[ "${i}" == "${p}" ]]; then | ||||
11 | ret=0 | ||||
12 | break | ||||
13 | fi | ||||
Junxiao Shi | 439d972 | 2015-03-20 15:08:44 -0700 | [diff] [blame] | 14 | done |
Davide Pesavento | 956ac31 | 2016-09-20 19:11:30 +0200 | [diff] [blame] | 15 | |
16 | set ${saved_xtrace} | ||||
17 | return ${ret} | ||||
Junxiao Shi | 439d972 | 2015-03-20 15:08:44 -0700 | [diff] [blame] | 18 | } |