blob: e76a84a6016ff9c6a094dc279f01d7f65102e4db [file] [log] [blame]
Jonathan Hart518e5e72014-10-31 15:28:35 -07001#!/bin/bash
2
3validate_number () {
4 local re="^[0-9]+$"
5 if [[ ! $1 =~ $re ]] ; then
6 return 1
7 fi
8
9 return 0
10}
11
12find_node () {
13 if validate_number $1 ; then
14 # input is a number, try to find if an OC node is defined
15
16 oc_try="OC$1"
17 node=${!oc_try}
18
19 if [ -n "$node" ]; then
20 # node lookup succeeded, return node
21 echo $node
22 else
23 # node lookup failed, return original input
24 echo $1
25 fi
26
27 else
28 echo $1
29 fi
30
31 return 0
32}