**Why?** The brace expansion is simple text substitution. All possible text formed by the prefix, the postfix and the braces themselves are generated. In the example, these are only two: ''-i*.vob'' and ''-i''. The filename expansion happens **after** that, so there is a chance that ''-i*.vob'' is expanded to a filename - if you have files like ''-ihello.vob''. But it definitely doesn't do what you expected.
Please see:
* [[syntax:expansion:brace]]
===== Test-command =====
* ''if [ $foo ] ...''
* ''if [-d $dir] ...''
* ...
Please see:
* [[commands:classictest#pitfalls_summarized|The classic test command - pitfalls]]
===== Variables =====
==== Setting variables ====
=== The Dollar-Sign ===
There is no ''$'' (dollar-sign) when you reference the **name** of a variable! Bash is not PHP!
A variable name preceeded with a dollar-sign always means that the variable gets **expanded**. In the example above, it might expand to nothing (because it wasn't set), effectively resulting in...
As noted above, when you want to **expand** a variable i.e. "get the content", the variable name needs to be prefixed with a dollar-sign. But, since Bash knows various ways to quote and does word-splitting, the result isn't always the same.
Let's define an example variable containing text with spaces:
Exporting a variable means giving **newly created** (child-)processes a copy of that variable. It does **not** copy a variable created in a child process back to the parent process. The following example does **not** work, since the variable ''hello'' is set in a child process (the process you execute to start that script ''./script.sh''):
Exporting is one-way. The direction is from parent process to child process, not the reverse. The above example **will** work, when you don't execute the script, but include ("source") it:
If you need the specific value of ''$?'', there's no other choice. But if you need only a "true/false" exit indication, there's no need for ''$?''.
See also:
* [[scripting:basics#exit_codes | Exit codes]]
==== Output vs. Return Value ====
It's important to remember the different ways to run a child command, and whether you want the output, the return value, or neither.
When you want to run a command (or a pipeline) and save (or print) the **output**, whether as a string or an array, you use Bash's ''$(command)'' syntax: