You are not logged in.

#1 2012-11-25 15:30:19

Pacopag
Member
Registered: 2011-05-29
Posts: 287

[SOLVED] Bash: what does this mean #: <<'END' ?

Hi.  I'm looking at script I wrote a while back, and saw this line in it.

#: <<'END'

No doubt, I had a purpose, googled it, found this snippet, pasted it, it did what I wanted it to do, then moved on.  Does this mean anything, or is it just some cryptic comment?

Last edited by Pacopag (2012-11-25 16:35:22)

Offline

#2 2012-11-25 16:26:42

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: [SOLVED] Bash: what does this mean #: <<'END' ?

Looks like a comment to me tongue


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2012-11-25 16:28:55

Pacopag
Member
Registered: 2011-05-29
Posts: 287

Re: [SOLVED] Bash: what does this mean #: <<'END' ?

Yeah, me too.  What would it mean if the '#' were removed?

Offline

#4 2012-11-25 16:32:37

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: [SOLVED] Bash: what does this mean #: <<'END' ?

It's a commented here-document.  Everything between that line and a subsequent line with just "END" on it is ignored as a comment.  If the hash symbol weren't there it'd still be a here-document ... but it wouldn't do anything in that context as it follows a ":".  This would be just like `: filename` where filename was a file that include whatever was in your here-document.  The "true" colon doesn't use any input data, so it is ignored.

EDIT: scratch that, I was almost completely wrong.  The colon and the open here-document would in effect comment out everything in the here-document.  As that line is commented with the hash, the here-document is never opened.  So with the hash that line does absolutely nothing, and subsequent lines are interpreted by bash.  Without the hash, subsequent lines would be ignored.

Last edited by Trilby (2012-11-25 16:35:19)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2012-11-25 16:35:09

Pacopag
Member
Registered: 2011-05-29
Posts: 287

Re: [SOLVED] Bash: what does this mean #: <<'END' ?

Aha.  And now I remember it's purpose.  Thanks Trilby.

Edit:  Indeed, I remember now using it to comment out a block of the script.

Last edited by Pacopag (2012-11-25 16:36:00)

Offline

Board footer

Powered by FluxBB