LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-06-2012, 05:15 PM   #16
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037

Quote:
Originally Posted by pan64 View Post
Superfluous quotes make the code unnecessarily noisy. I do not like them, so I use them only when they really have meaning.
That's not an unreasonable position, but it is one that depends on experience. I take the stance here that new coders should get into the habit of doing it safely first. Once they really know what they are doing they can make their own decisions.

Besides, eliminating all superfluous syntax is not always the best option. Keeping your code clear, consistent, and readable is usually more important than simple terseness. There are times when I've even put unnecessary quotes around unbroken string literals (in array setting brackets, say) just because they matched the other entries around them that did need them. It helped make it clear at a glance that all the values were part of the same group and type of data.


Quote:
Originally Posted by leib
thanks david, and thanks for the links. i just got in the habit of ${var} and try to do that when i can. i know it is not required, but i feel better safe then sorry.
Well, again, the brackets do nothing outside of the situations I mentioned before. I went through a short period where I put them everywhere too, and thoroughly regretted it later when I went back to update some old scripts I had written. I felt that the code was uncomfortable to read and edit, to say the least. But it is your choice.


I guess my point is that there's a difference between useful consistency and pointless consistency. I consider quotes to be of the former, for the most part, as they can often have a real effect on the code, and bracketed variables the latter, as they don't.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH function using if,then,else mrmnemo Programming 7 05-02-2011 03:13 AM
[SOLVED] Setting function default in a bash script - Bash sixtensixone Linux - General 13 01-08-2011 01:44 PM
Bash array Add function example using indirect array reference as function argument bobywelsh Programming 10 07-05-2010 04:44 AM
Question about Bash and the "until" function daYz Programming 11 08-14-2006 11:34 AM
Bash looping or function within a function FirmbIT Programming 2 04-24-2006 01:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration