News for hackers. Stuff that matters.
Re:Bash Shell Scripting in 10 seconds by nescafe on Monday February 27, 2012 @09:18AM (#3639020)
Linked article is actually a really horrible intro to bash -- at best, it is an OK intro to pre-POSIX bourne shell scripting.

Specifically:

* test and [ ] are fraught with parameter expansion peril. Use [[ ]] instead.

* The author uses single quotes around strings that are demonstrating parameter expansion. Single quotes inhibit parameter expansion, so every one of those examples is wrong.

* select is a better tool than read; case for most of his case-relasted demos.

* Backticks ( ` ` ) are the devil.

At least he points people greg's wiki at the end.

Re:Bash Shell Scripting in 10 seconds by acqq on Monday February 27, 2012 @09:32AM (#3639063)
Whoever made the guide is unexperienced in the tasks he writes about. Otherwise he'd know about [[ and ((. Were it an intro for non-bash shells, it would be an acceptable omission. And you're not really explaining how to write conditions if you aren't explaining this:

    # d=abc
    # [ $d -eq 25 ]
    -bash: [: abc: integer expression expected
It also looks to me that aboutlinux.info is in fact just a for-SEO-purposes generated site. Anybody knows more?
Re:Bash Shell Scripting in 10 seconds by ez77 on Monday February 27, 2012 @03:23PM (#3640460)
Actually POSIX does not recognize double brackets [1]:

"The KornShell-derived conditional command (double bracket [[]]) was removed from the shell command language description in an early proposal. Objections were raised that the real problem is misuse of the test command ( [), and putting it into the shell is the wrong way to fix the problem. Instead, proper documentation and a new shell reserved word ( !) are sufficient."

The entire section on test is full of advice on the proper use of test(1).

[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/te...

Re:Bash Shell Scripting in 10 seconds by acqq on Monday February 27, 2012 @04:06PM (#3640647)
The article writes about Bash and not about POSIX standardization of test command which omits double brackets.
Re:Bash Shell Scripting in 10 seconds by ez77 on Monday March 05, 2012 @08:32PM (#3669255)
I replied to a specific comment, not to the article. In particular, nescafe said this was "an OK intro to pre-POSIX bourne shell scripting". I took this to mean that he would provide POSIX-endorsed suggestions. The double brackets, at least, are not "post-POSIX".
Re:Bash Shell Scripting in 10 seconds by AlexandrB on Monday February 27, 2012 @10:55AM (#3639360)
Do you know of a better intro? I wasn't even aware of [[ ]] :(
Re:Bash Shell Scripting in 10 seconds by nescafe on Monday February 27, 2012 @11:06AM (#3639410)
Re:Bash Shell Scripting in 10 seconds by acqq on Monday February 27, 2012 @11:05AM (#3639405)
Demystify Bash test and comparison functions

http://news.ycombinator.com/item?id=3639401

Re:Bash Shell Scripting in 10 seconds by morsch on Monday February 27, 2012 @09:29AM (#3639054)
What's wrong with using backticks?
Re:Bash Shell Scripting in 10 seconds by babarock on Monday February 27, 2012 @09:30AM (#3639056)
They don't nest as well as $()
Re:Bash Shell Scripting in 10 seconds by gbog on Monday February 27, 2012 @10:15AM (#3639214)
And backticks can easily slip in when you want to tab or escape, then you can mistake them with a single-quote.

Where they are really the evilest evil is in PHP. Such a dangerous things, nearly invisible!

Re:Bash Shell Scripting in 10 seconds by ajross on Monday February 27, 2012 @12:04PM (#3639617)
grumbling guy with beard walks by, mumbles "Here's a dollar kid, get yourself a real font." And walks on...

Unless your shell and editor are displaying in courier, or you use extremely small glyphs (I've seen folks doing terrible things to their font scaling on 100dpi mac screens trying to get more lines on the screen) that should not be a problem. Certainly the Vera Mono font family gets this right; a backtick is quite distinct.