Fix all grep statements failing under -o errexit.
Change-Id: I0591a2ba7351d598eb5b29d68a83ce6290600938
... | ... |
@@ -55,7 +55,7 @@ function upload_image { |
55 | 55 |
mkdir -p $FILES/images |
56 | 56 |
IMAGE_FNAME=`basename "$image_url"` |
57 | 57 |
if [[ $image_url != file* ]]; then |
58 |
- # Downloads the image (uec ami+aki style), then extracts it. |
|
58 |
+ # Downloads the image (uec ami+akistyle), then extracts it. |
|
59 | 59 |
if [[ ! -f $FILES/$IMAGE_FNAME || "$(stat -c "%s" $FILES/$IMAGE_FNAME)" = "0" ]]; then |
60 | 60 |
wget -c $image_url -O $FILES/$IMAGE_FNAME |
61 | 61 |
if [[ $? -ne 0 ]]; then |
... | ... |
@@ -103,12 +103,12 @@ function upload_image { |
103 | 103 |
vmdk_net_adapter="" |
104 | 104 |
|
105 | 105 |
# vmdk adapter type |
106 |
- vmdk_adapter_type="$(head -25 $IMAGE | grep -a -F -m 1 'ddb.adapterType =' $IMAGE)" |
|
106 |
+ vmdk_adapter_type="$(head -25 $IMAGE | { grep -a -F -m 1 'ddb.adapterType =' $IMAGE || true; })" |
|
107 | 107 |
vmdk_adapter_type="${vmdk_adapter_type#*\"}" |
108 | 108 |
vmdk_adapter_type="${vmdk_adapter_type%?}" |
109 | 109 |
|
110 | 110 |
# vmdk disk type |
111 |
- vmdk_create_type="$(head -25 $IMAGE | grep -a -F -m 1 'createType=' $IMAGE)" |
|
111 |
+ vmdk_create_type="$(head -25 $IMAGE | { grep -a -F -m 1 'createType=' $IMAGE || true; })" |
|
112 | 112 |
vmdk_create_type="${vmdk_create_type#*\"}" |
113 | 113 |
vmdk_create_type="${vmdk_create_type%\"*}" |
114 | 114 |
|
... | ... |
@@ -119,7 +119,7 @@ function upload_image { |
119 | 119 |
elif [[ "$vmdk_create_type" = "monolithicFlat" || \ |
120 | 120 |
"$vmdk_create_type" = "vmfs" ]]; then |
121 | 121 |
# Attempt to retrieve the *-flat.vmdk |
122 |
- flat_fname="$(head -25 $IMAGE | grep -G 'RW\|RDONLY [0-9]+ FLAT\|VMFS' $IMAGE)" |
|
122 |
+ flat_fname="$(head -25 $IMAGE | { grep -G 'RW\|RDONLY [0-9]+ FLAT\|VMFS' $IMAGE || true; })" |
|
123 | 123 |
flat_fname="${flat_fname#*\"}" |
124 | 124 |
flat_fname="${flat_fname%?}" |
125 | 125 |
if [[ -z "$flat_name" ]]; then |
... | ... |
@@ -190,7 +190,7 @@ function upload_image { |
190 | 190 |
fi |
191 | 191 |
if $descriptor_found; then |
192 | 192 |
vmdk_adapter_type="$(head -25 $descriptor_url |"` |
193 |
- `"grep -a -F -m 1 'ddb.adapterType =' $descriptor_url)" |
|
193 |
+ `" { grep -a -F -m 1 'ddb.adapterType =' $descriptor_url || true; })" |
|
194 | 194 |
vmdk_adapter_type="${vmdk_adapter_type#*\"}" |
195 | 195 |
vmdk_adapter_type="${vmdk_adapter_type%?}" |
196 | 196 |
fi |
... | ... |
@@ -203,7 +203,7 @@ function upload_image { |
203 | 203 |
# NOTE: For backwards compatibility reasons, colons may be used in place |
204 | 204 |
# of semi-colons for property delimiters but they are not permitted |
205 | 205 |
# characters in NTFS filesystems. |
206 |
- property_string=`echo "$IMAGE_NAME" | grep -oP '(?<=-)(?!.*-).*[:;].*[:;].*$'` |
|
206 |
+ property_string=`echo "$IMAGE_NAME" | { grep -oP '(?<=-)(?!.*-).*[:;].*[:;].*$' || true; }` |
|
207 | 207 |
IFS=':;' read -a props <<< "$property_string" |
208 | 208 |
vmdk_disktype="${props[0]:-$vmdk_disktype}" |
209 | 209 |
vmdk_adapter_type="${props[1]:-$vmdk_adapter_type}" |