wrong bash statements. (#6071)

here is my test result:

[root@localhost ~]# sh -c 'for i in {1..100}; do sleep 1; if dig www.baidu.com;then exit 0; fi; exit 1'
sh: -c: line 1: syntax error: unexpected end of file
[root@localhost ~]# sh -c 'for i in {1..100}; do sleep 1; if dig www.baidu.com;then exit 0; fi;done; exit 1'

; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7 <<>> www.baidu.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27927
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.baidu.com.                 IN      A

;; ANSWER SECTION:
www.baidu.com.          1125    IN      CNAME   www.a.shifen.com.
www.a.shifen.com.       106     IN      A       180.97.33.107
www.a.shifen.com.       106     IN      A       180.97.33.108

;; Query time: 16 msec
;; SERVER: 192.168.0.1#53(192.168.0.1)
;; WHEN: Fri Oct 27 02:42:38 EDT 2017
;; MSG SIZE  rcvd: 101

[root@localhost ~]# echo $?
0
[root@localhost ~]#
pull/6076/head
xuhuilong 2017-10-28 01:22:15 +08:00 committed by Steve Perry
parent adcce7536f
commit c3b684f9b6
1 changed files with 1 additions and 1 deletions

View File

@ -75,7 +75,7 @@ Here are some ideas for how to use Init Containers:
* Wait for a service to be created with a shell command like:
for i in {1..100}; do sleep 1; if dig myservice; then exit 0; fi; exit 1
for i in {1..100}; do sleep 1; if dig myservice; then exit 0; fi; done; exit 1
* Register this Pod with a remote server from the downward API with a command like: