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 8928595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:28:42+00:00 2026-06-15T08:28:42+00:00

I want to store verbatim text in Bash variables. I have an approach described

  • 0

I want to store verbatim text in Bash variables. I have an approach described here and I would like criticism and suggestions on improving this approach. Currently, the specific application is to have functions within a shell script library that are, to some extent, self documenting. Here is the sort of function I have in mind:

templateFunction(){
################################################################################
interrogationInformation=$(cat << 2012-09-26T1909
    <class>
        setup
    </class>
    <description>
        This is a natural language description of this function.
    </description>
    <prerequisiteFunctions>
        myFunction1
        myFunction2
    </prerequisiteFunctions>
    <prerequisitePrograms>
        myProgram1
        myProgram2
    </prerequisitePrograms>
2012-09-26T1909
)
################################################################################
if [ "${1}" != "-interrogate" ]; then #interrogation
    echo "function template"
fi #interrogation
}

An interrogation function can query the template function and the template function then returns some information about itself by way of the ‘verbatim’ variable interrogationInformation. The interrogation function parses this information.

In due course, it is likely that special characters such as quotation marks could be stored in these ‘verbatim’ variables (for example, in natural language). These variables could be used also for building code files, such as for web pages. The difficulty in using this approach is that cat can vary between distributions and the resulting behaviour can be unpredictable. Essentially, I would like criticism of my approach and suggestions for improvement. Perhaps one improvement would be a better (preferably standard) program than cat as used in this case.

I thank you very much for any suggestions.

  • 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-06-15T08:28:44+00:00Added an answer on June 15, 2026 at 8:28 am

    You can use read instead of cat as follows:

    IFS= read -d '' interrogationInformation << "EOF"
        <class>
            setup
        </class>
        <description>
            This is a natural language description of this function.
        </description>
        <prerequisiteFunctions>
            myFunction1
            myFunction2
        </prerequisiteFunctions>
        <prerequisitePrograms>
            myProgram1
            myProgram2
        </prerequisitePrograms>
    EOF
    

    Note that quoting EOF prevents any parameter expansion in the text.

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

Sidebar

Related Questions

I want to store the TF-IDF matrix so I don't have to recalculate it
I have this code: I want to store some vales in a day of
I want store data from an html page to a text file using javascript
I have a long string that I want store it as a list. But
I want to store some genomic positions (chromosome,position) using MongoDB. something like: { chrom:chr2,
Some code here, I want store mysql query result into an array with php,
I have 15k entries and i want store them in local database. Further in
I want store some article into database. I use php and mysql. Whether have
I want to store web pages in compressed text files (CSV). To achieve the
I am a new developer on Android and I want store user data in

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.