Skip to main content
added 24 characters in body
Source Link
codefx
  • 10.7k
  • 17
  • 59
  • 89

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"

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

read -d '' QUERY <<EOF
UPDATE table_name SET
 field1 = 'value',
 field2 = 'value'
 WHERE id = 1;
EOF
mysql table_name -e "$QUERY"

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"
Source Link
codefx
  • 10.7k
  • 17
  • 59
  • 89

How to make read -d return true

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

read -d '' QUERY <<EOF
UPDATE table_name SET
 field1 = 'value',
 field2 = 'value'
 WHERE id = 1;
EOF
mysql table_name -e "$QUERY"