Reputation: 10522
I am using the following construct to set a multiline string in bash shell. But this always returns false which does not work when I set set -e
. How can I make this to return success?
#!/bin/bash
set -x
set -e
read -d '' QUERY <<EOF
UPDATE table_name SET
field1 = 'value',
field2 = 'value'
WHERE id = 1;
EOF
mysql table_name -e "$QUERY"
Upvotes: 0
Views: 47
Reputation: 13459
While not an answer to your original question, this does get your problem solved. Consider using substitution and e.g. cat
QUERY=$(cat <<EOM
test
test2
EOM
)
mysql table_name -e "$QUERY"
Please, be aware of safety issues if you're reading those values from unsanitized input.
Upvotes: 2