Alexander Afanasyev | c7c9900 | 2015-10-09 17:27:30 -0700 | [diff] [blame] | 1 | has() { |
Alexander Afanasyev | 984ca9d | 2016-12-19 13:09:14 -0800 | [diff] [blame] | 2 | local saved_xtrace |
| 3 | [[ $- == *x* ]] && saved_xtrace=-x || saved_xtrace=+x |
| 4 | set +x |
| 5 | |
Alexander Afanasyev | c7c9900 | 2015-10-09 17:27:30 -0700 | [diff] [blame] | 6 | local p=$1 |
| 7 | shift |
Alexander Afanasyev | 984ca9d | 2016-12-19 13:09:14 -0800 | [diff] [blame] | 8 | local i ret=1 |
| 9 | for i in "$@"; do |
| 10 | if [[ "${i}" == "${p}" ]]; then |
| 11 | ret=0 |
| 12 | break |
| 13 | fi |
Alexander Afanasyev | c7c9900 | 2015-10-09 17:27:30 -0700 | [diff] [blame] | 14 | done |
Alexander Afanasyev | 984ca9d | 2016-12-19 13:09:14 -0800 | [diff] [blame] | 15 | |
| 16 | set ${saved_xtrace} |
| 17 | return ${ret} |
Alexander Afanasyev | c7c9900 | 2015-10-09 17:27:30 -0700 | [diff] [blame] | 18 | } |