Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7622341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:25:37+00:00 2026-05-31T04:25:37+00:00

This is a small question I know. We are writing a Bash highlighter in

  • 0

This is a small question I know. We are writing a Bash highlighter in Ruby and need to implement heredoc highlighting. The two formats I have seen are this. Note the space before the EOF

cat <<EOF
Hello
World
EOF

cat << EOF
Hello
World
EOF

The question is, is it incorrect/unofficial/bad practice to use a space before the first EOF?

  • gnu.org/software/bash/manual/bashref
  • linux.die.net/man/1/bash
  • tldp.org/LDP/abs/html/here-docs.html
  • wikipedia.org/wiki/Here_document
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:25:38+00:00Added an answer on May 31, 2026 at 4:25 am

    The POSIX Shell Command Language specification explicitly specifies that the file-descriptor number, if any, “immediately precede the redirection operator”; but it makes no similar requirement that the redirection operator immediately precede the word. The token recognition rules imply that any spaces would be discarded between the redirection operator and the word, so I think that any correct implementation should accept such spaces. (Admittedly, this would be more reassuring if it weren’t that the same token recognition rules imply the same thing about spaces between the file-descriptor number and the redirection operator.)

    Although the Bash Reference Manual‘s examples for heredocs don’t include a space before the word, it does give other examples with redirections that do include a space before the word, and nothing in either the POSIX spec or the Bash Reference Manual gives any reason to think of heredocs’ word as being different in this respect from the word in any other kind of redirection, so I don’t think it should be thought of as bad practice. I think your syntax-highlighter should support both, unless one of the goals of the project is to enforce some sort of standard style for such things.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Disclaimer First of all, I know this question (or close variations) have been
I have been pondering writing this question for quite some time. I work for
I've got this small question - given a bitmask of weekdays (e.g., Sunday =
This question is about programming small microcontrollers without an OS. In particular, I'm interested
This might seem like a stupid question I admit. But I'm in a small
As I stated in this question , I am using SDL for a small
Sorry for this long post. The question is however small but requires full detail.
I have this small code library that I'm considering releasing into Open Source. I
I have this small SQL query. SELECT a.`id` , a.`title` , a.`date` , (
I have this small class called City that simply holds some information about a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.