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

  • Home
  • SEARCH
  • 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 8070007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:15:20+00:00 2026-06-05T13:15:20+00:00

Yesterday I’ve discovered that Bash provides a means to mark variables as read-only, using

  • 0

Yesterday I’ve discovered that Bash provides a means to mark variables as read-only, using the readonly keyword:

readonly hello="hello"
hello="world" # error message, Bash refuses to reassign the variable

This seems like a nice feature, still, I’ve never seen this used in any Bash script. Is there any reason not to use this extensivly? Is it actually portable?

  • 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-05T13:15:22+00:00Added an answer on June 5, 2026 at 1:15 pm

    readonly is useful for some variables that are set by bash, for example $UID – non-readonly values like $LOGNAME and $USER are easy for the user to alter.

    If you find readonly useful then use it! Not many people use readonly, but don’t let that bother you. Downside – like other variable attributes, readonly attribute is not passed on with an exported variable, unless the child process is another bash.

    One use of readonly is to apply it to a function. That’s not widely done, but it solves a support issue of (by mistake) having two functions of the same name, which can be an issue when using functions stored outside the script.

    ksh also supports readonly (as an alias).

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

Sidebar

Related Questions

Yesterday I discovered an odd bug in rather simple code that basically gets text
Yesterday I learned that inline assembly (with the __asm keyword) is not supported under
Yesterday I was trying to implement a Listener for a SelectManyListbox using Ajax in
Yesterday, my supervisor told me that tmp-file-based session should be THE answer to session
Yesterday I felt in big issue that happens with all my projects. After I
Yesterday I notice that some thing kept writing with 1.48M/s bursting speed every 30s
Yesterday I ran into a g++ (3.4.6) compiler problem for code that I have
Yesterday morning I noticed Google Search was using hash parameters: http://www.google.com/#q=Client-side+URL+parameters which seems to
Yesterday i noticed a foreign key column in a details table that linked directly
Yesterday I read some code of a colleague and came across this: class a_class

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.