Awesome. That was exactly what I was looking for. worry about quoting and interpolation issues.
This is exactly what I'm concerned about so using read is the solution I'm looking for. Thanks so much for the prompt response! Kind regards, Ted Stresen-Reuter On Tue, Jan 22, 2019 at 10:17 PM Sam Hathaway <[email protected]> wrote: > I’m assuming you’re using bash. > > If you are trying to set a shell variable and then print it out, you will > need to do something like this: > > SQL="INSERT INTO mytable(`field1`, `field2`)VALUES('val1', 'val2')"echo "$SQL" > > It is possible to use a here document, but it’s not really the right tool > for the job IMO. > > read -r -d '' SQL <<'EOF'INSERT INTO mytable(`field1`, > `field2`)VALUES('val1', 'val2')EOFecho "$SQL" > > The one advantage I can think of here over using a multiline string is > that you don’t have to worry about quoting and interpolation issues. > > Hope this helps! > -sam > > On 22 Jan 2019, at 17:01, Gustave Stresen-Reuter wrote: > > Hi, > > I'm trying to test a heredoc in a worksheet but I can't quite work out the > syntax. > > All of the examples I've seen look like this: > > cat << EOF > SQL > INSERT INTO mytable > (`field1`, `field2`) > VALUES > ('val1', 'val2') > SQL > > echo "$SQL" > > But when I try that in a worksheet, the echo is a blank line. > > What am I doing wrong? > > Thanks in advance. > > Ted Stresen-Reuter > > -- > This is the BBEdit Talk public discussion group. If you have a > feature request or need technical support, please email > "[email protected]" rather than posting to the group. > Follow @bbedit on Twitter: <https://www.twitter.com/bbedit> > --- > You received this message because you are subscribed to the Google Groups > "BBEdit Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/bbedit. > > -- > This is the BBEdit Talk public discussion group. If you have a > feature request or need technical support, please email > "[email protected]" rather than posting to the group. > Follow @bbedit on Twitter: <https://www.twitter.com/bbedit> > --- > You received this message because you are subscribed to the Google Groups > "BBEdit Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/bbedit. > -- This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "[email protected]" rather than posting to the group. Follow @bbedit on Twitter: <https://www.twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/bbedit.
