Skip to main content

Timeline for What is "declare" in Bash?

Current License: CC BY-SA 4.0

9 events
when toggle format what by license comment
Jun 22, 2019 at 22:25 comment added LL3 @G-Man Naturally you're very right indeed. Yet.. I don't know.. if this answer of mine has any little reason to exist among the other excellent ones by fra-san and Kusalananda is possibly because it handles only a couple of particular concepts in an (intentionally) overly rich way, though necessarily stripped of collateral details because otherwise it'd be even longer and tedious. A tale for absolute beginners, more than a proper description of what declare does. Perhaps your very comment, which I upvoted, may serve well as the footnote you mention ?
Jun 22, 2019 at 19:00 comment added G-Man Says 'Reinstate Monica' You mention foo="bar" and declare foo="bar".  You might want to mention (if only in a footnote) that, in a shell function, declare foo="bar" creates a local variable and foo="bar" creates a global variable.
Apr 6, 2019 at 23:50 history bounty awarded CommunityBot
Apr 6, 2019 at 23:50 comment added user149572 Thank you, I think it's okay for me to learn on this right now, I just need an explanation I can understand and I should re-read your entire answer today, I'm here around.
Apr 6, 2019 at 21:45 comment added LL3 @JohnDoea I see. Maybe you might just leave this topic for the moment. It’s probably too soon to grasp this concept at the current point of your learning. Anyways I’ve expanded my answer with more examples and also a little personal addendum as to how I think you should proceed. I’ve also put horizontal lines to delimit the general explanation of declare from the specific explanation of -n from the personal addendum. I’ve also done a bit of rewording here and there but nothing substantial, so I think you may just re-read the -n part plus the little addendum.
Apr 6, 2019 at 21:43 history edited LL3 CC BY-SA 4.0
more example cases, fixed grammar, some minor rewording
Apr 6, 2019 at 8:09 comment added user149572 That is - why would one give this attribute
Apr 6, 2019 at 2:07 comment added user149572 LL3 I like your answer very much and I thumbed up: I finally understand what declare does --- not declaring variables but declaring their attributes; yet sadly I lost track when you started to explain what is a name-ref. I got no idea what it does and why to use it.
Apr 5, 2019 at 18:03 history answered LL3 CC BY-SA 4.0