Committed by
Gerrit Code Review
ONOS-2854 Fixed a few bugs and made tiny improvements to shell scripts.
Change-Id: I624dc05300944dbc8b1f408bf725c49ff96f68c2
Showing
3 changed files
with
36 additions
and
37 deletions
... | @@ -148,41 +148,41 @@ function nuke { | ... | @@ -148,41 +148,41 @@ function nuke { |
148 | spy "$@" | cut -c7-11 | xargs kill | 148 | spy "$@" | cut -c7-11 | xargs kill |
149 | } | 149 | } |
150 | 150 | ||
151 | -# Edit a cell file by providing a cell name. Opens the cell file in $EDITOR. | 151 | +# Edit a cell file by providing a cell name; opens the cell file in $EDITOR. |
152 | -function vicell() { | 152 | +function vicell { |
153 | - local apply=false | 153 | + local apply=false |
154 | - local create=false | 154 | + local create=false |
155 | - local cdf="" | 155 | + local cdf="" |
156 | - local cpath="${ONOS_ROOT}/tools/test/cells/" | 156 | + local cpath="${ONOS_ROOT}/tools/test/cells/" |
157 | - | 157 | + |
158 | - if [ -z "$1" ] || [ "$1" = "-h" ] ; then | 158 | + if [ -z "$1" ] || [ "$1" = "-h" ] ; then |
159 | - printf "usage: vicell [file] [options]\n\noptions:\n" | 159 | + printf "usage: vicell [file] [options]\n\noptions:\n" |
160 | - printf "\t-a: apply the cell after editing\n" | 160 | + printf "\t-a: apply the cell after editing\n" |
161 | - printf "\t-e: [editor] set EDITOR to [editor] (default *vi*)\n" | 161 | + printf "\t-e: [editor] set EDITOR to [editor] (default *vi*)\n" |
162 | - printf "\t-c: create cell file if none exist\n\n" | 162 | + printf "\t-c: create cell file if none exist\n\n" |
163 | - return 1 | 163 | + return 1 |
164 | - fi | 164 | + fi |
165 | - | 165 | + |
166 | - while [ $# -gt 0 ]; do | 166 | + while [ $# -gt 0 ]; do |
167 | - case "$1" in | 167 | + case "$1" in |
168 | - -a) apply=true ;; | 168 | + -a) apply=true ;; |
169 | - -e) EDITOR=$2; shift ;; | 169 | + -e) EDITOR=$2; shift ;; |
170 | - -c) create=true ;; | 170 | + -c) create=true ;; |
171 | - *) cdf="$1" ;; | 171 | + *) cdf="$1" ;; |
172 | - esac | 172 | + esac |
173 | - shift | 173 | + shift |
174 | - done | 174 | + done |
175 | - | 175 | + |
176 | - if [ ! -e "${cpath}${cdf}" ] && [ "$create" = "false" ]; then | 176 | + if [ ! -e "${cpath}${cdf}" ] && [ "$create" = "false" ]; then |
177 | - printf "${cdf} : no such cell\n" && return 1 | 177 | + printf "${cdf} : no such cell\n" && return 1 |
178 | - fi | 178 | + fi |
179 | - | 179 | + |
180 | - if [ -z "${EDITOR}" ] || [ -x "$(which ${EDITOR})" ]; then | 180 | + if [ -z "${EDITOR}" ] || [ -x "$(which ${EDITOR})" ]; then |
181 | - unset EDITOR && vi ${cpath}${cdf} | 181 | + unset EDITOR && vi ${cpath}${cdf} |
182 | - else | 182 | + else |
183 | - $EDITOR ${cpath}${cdf} | 183 | + $EDITOR ${cpath}${cdf} |
184 | - fi | 184 | + fi |
185 | - ($apply) && cell ${cdf} | 185 | + ($apply) && cell ${cdf} |
186 | } | 186 | } |
187 | 187 | ||
188 | # autocomplete for certain utilities | 188 | # autocomplete for certain utilities | ... | ... |
... | @@ -44,7 +44,7 @@ function _cell-opts () { | ... | @@ -44,7 +44,7 @@ function _cell-opts () { |
44 | fi | 44 | fi |
45 | } | 45 | } |
46 | 46 | ||
47 | -complete -F _cell-opts cell | 47 | +complete -F _cell-opts cell vicell |
48 | 48 | ||
49 | 49 | ||
50 | # Tab completion settings for onos-create-app. | 50 | # Tab completion settings for onos-create-app. | ... | ... |
... | @@ -34,7 +34,6 @@ fi | ... | @@ -34,7 +34,6 @@ fi |
34 | 34 | ||
35 | case $2 in | 35 | case $2 in |
36 | start|stop|restart|status) | 36 | start|stop|restart|status) |
37 | - | ||
38 | # Select the target | 37 | # Select the target |
39 | if [ "${1}" = "--cell" ]; then | 38 | if [ "${1}" = "--cell" ]; then |
40 | nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2) | 39 | nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2) | ... | ... |
-
Please register or login to post a comment