4 ms·
Yes, you are correct. But some people crazy to write everything in shell scripts.
by fizerkhan 13y ago
Yes, you are correct. But some people crazy to write everything in shell scripts.
- Fuxy 13y agoI 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.
- coolj 13y agohttp://www.tldp.org/LDP/abs/html/ 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#ARGLIST http://www.tldp.org/LDP/abs/html/internalvariables.html#ARGL...
- barrkel 13y agoFree 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.
- unhammer 13y agohttp://mywiki.wooledge.org/BashGuide http://mywiki.wooledge.org/BashGuide is the ultimate bash guide, along with http://mywiki.wooledge.org/BashFAQ 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 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).
- unhammer 13y agoAlso, 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.
- 616c 13y agoOf 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. :-)