News for hackers. Stuff that matters.
Re:What I learned from others' shell scripts by fizerkhan on Wednesday August 14, 2013 @03:36AM (#6210304)
Yes, you are correct. But some people crazy to write everything in shell scripts.
Re:What I learned from others' shell scripts by Fuxy on Wednesday August 14, 2013 @04:37AM (#6210472)
I find shell scripts confuses the heck out of me whenever they try to do something a little more complicated the piping.

Even this left me a but confused like how do the functions get the input parameters does the * in echo -e "$RED$*$NORMAL" have something to do with it?

There's just so many obscure ways of doing the same thing not to mention there's very few good places to teach you shell scripting and shell scripting best practices.

I'd rather just go with python. It's easier to read.

Re:What I learned from others' shell scripts by coolj on Wednesday August 14, 2013 @04:57AM (#6210509)
http://www.tldp.org/LDP/abs/html/

TLDP's Advanced Bash-Scripting Guide is a great resource for learning bash.

For example, this section talks about the meaning of "$*":

http://www.tldp.org/LDP/abs/html/internalvariables.html#ARGL...

Re:What I learned from others' shell scripts by barrkel on Wednesday August 14, 2013 @12:59PM (#6212693)
Free advice: you almost never want $. Almost always what you want is $@, usually in the form "$@". It doesn't matter for this example, but $ is usually a code smell.
Re:What I learned from others' shell scripts by unhammer on Wednesday August 14, 2013 @05:27AM (#6210584)
http://mywiki.wooledge.org/BashGuide is the ultimate bash guide, along with http://mywiki.wooledge.org/BashFAQ

For learning the differences between POSIX sh and bash (which can trip you up if you want to run on systems without bash, or if you simply don't know that #!/bin/sh is different from #!/bin/bash), see http://mywiki.wooledge.org/Bashism

And regarding how to parse your example, the $* in a string expands to all input parameters to the function, separated by the first character of the IFS variable (e.g. space).

Re:What I learned from others' shell scripts by unhammer on Wednesday August 14, 2013 @05:29AM (#6210588)
Also, there's no reason to use uppercase for all variables, it's just that environment variables are by convention uppercase so people seem to think their local vars need to be uppercase too.
Re:What I learned from others' shell scripts by 616c on Wednesday August 14, 2013 @04:52AM (#6210502)
Of course, there are also some people crazy enough to write web apps in C, C++, or dare I say Haskell! The latter has become popular, but every tool has a purpose, and every tool can be re-invented, like if you are a garbage social app so popularly social you compile your PHP into C++ and give it a music genre name.

I am sure no one will get that reference. :-)

Re:What I learned from others' shell scripts by cgag on Wednesday August 14, 2013 @05:04PM (#6214256)
What's crazy about using an extremely high level language (haskell) for web dev?
Re:What I learned from others' shell scripts by 616c on Thursday August 15, 2013 @01:14AM (#6216288)
It isn't as far as I am concerned, but it might upset some people.