Questions tagged [heredoc]

A Here-document is a special syntax of writing literal strings in sourcecode, used by different programming languages.

A heredoc or Here-Document is a way of writing literal strings in sourcecode. Many languages use heredocs: PHP, Perl, C#...

Although syntax can differ between programming languages, most heredocs start by putting a keyword, and end when the keyword is encountered as the only element on a line (no spaces, tabs or other characters are allowed). Perl example:

my $text = <<KEYWORD; #Any non-reserved word would do
This is some text.
It can contain $othervariables which will be replaced
Unless KEYWORD was between single quotes, in Perl.
KEYWORD
761 questions
0
votes
1 answer

Formatted text inside Quill editor on page load

I have what I think should be a very simple question. How do you put formatted multi-line strings into the quill editor on page load? I want to use a quill editor to let the user enter json in, but I want to have certain json in the quill field…
dcashman
  • 197
  • 10
0
votes
1 answer

KSH, read used in a pipeline

I'm trying to learn Here Documents IO-redirections in Korn Shell. I used "read" builtin to test the concepts. I wrote a sample program as follows #!/usr/bin/ksh cat << ONE | wc -l | read word | if [ $word -eq 1 ]; then cat << TWO ; fi | wc -l |…
Abis
  • 155
  • 8
0
votes
1 answer

How do I escape a keyword which is a command in a shell script?

Inside my shell script I have #!/bin/bash var1=$1 var2=$2 cat<
Saurabh Gupta
  • 506
  • 1
  • 4
  • 18
0
votes
1 answer

How to use EOD as a array value

How to use EOD , heredoc as a string array value? class W { const ERROR = [ 'en'=>'<<
user6827096
  • 1,186
  • 1
  • 11
  • 26
0
votes
1 answer

How to escape { and } in heredoc PHP

I want to use { in a string which is being stored in heredoc in PHP, how to use it? how to escape? echo $heredoc = << Welcome {$myname}

HTML; The output is Welcome Aayush Sinha But the output required is Welcome {Aayush Sinha}.
Aayush Sinha
  • 377
  • 4
  • 18
0
votes
4 answers

Defining a bunch of functions with eval (PHP)

Is this anywhere near something acceptable? I need a function for each HTML tag, and they need to be defined for later use in a Heredoc string. This is my code so far. $value) { …
0
votes
0 answers

Variable inside a bash heredoc

It looks like the variables is not getting populated eventhough in theory it should. Am I missing something? echo "Setting up: $db" cat < ./mysql_setup.sql create database $db; grant all on $db.* To $adm_user@localhost identified by…
Jimson James
  • 2,937
  • 6
  • 43
  • 78
0
votes
2 answers

Multiline bash using sed to remove leading whitespace: quotes erroneously preserved in command argument

I am running this piece of code: annotate-output $((sed -E 's/^[ ]+//;' <<____COMMAND sshfs foo_user@fooserver.com:/sftp_folder /var/sshfs.sandbox/server.com -o user=foo_user ,reconnect ,ServerAliveInterval=15 …
lucid_dreamer
  • 362
  • 4
  • 9
0
votes
0 answers

How to use custom code inside multiline strings?

I am trying to run PHP code inside DELIMETER but it does not work. I want to do a box to show all quantity available on my stock. This is my code: $product = <<