|
|
|
|
|
by chubot
4443 days ago
|
|
Here are the quoting rules I use: - Avoid paths with spaces :)
- If you have to handle paths with spaces, use double quotes everywhere,
e.g. "$pidfile".
- Always use "$@". I've never found a reason to use $@ or $* unquoted.
I also write unit tests (in shell) if there is something unusual I know I have to handle.That's it. I don't think it's hard at all, although you will certainly see scripts in the wild where the author was confused about quoting, and quoting hacks pile upon hacks. If you use a consistent style, it's very smiple. There is a learning curve like there is with any language, but it's totally worth it. Shell is an extremely powerful language, and saves you MANY lines of Python code. I would say Python is definitely the easiest language to learn, but bash is not harder than say JavaScript. |
|
I'd like to add: Always use double quotes around paths. Or is there something I'm missing here?