Two bugs were introduced when adding configuration file support:
* Passing the message as script parameter was not working when `-c` option was
used (eg. `script -c cfg msg`)
* `-c` configuration file was not loaded properly
This commit fixes these 2 bugs.
The script can now be configured using configuration files.
If a file named ".freemobile-smsapi" is located next to the script or in user's
home directory, such file will be read to load
Alternatively, a file path can be specified using `-c` option at runtime.
This commit makes the script accept option to specify configuration filepath
and also look for configuration files in specific places.
This commit does not change script behavior, it only deals with code syntax and
standards:
* Long lines were capped to 80 chars
* Long commands were splited into multiple for improved readability
* Variables are now all using the curly brace syntax
Due to how stdin is read, the message gets a trailing "\n". sed was used to
remove it but this commit use shell variable mangling "${var%Pattern}"
instead (faster and nicer).
To simplify and improve readability of configuration options, use of standard
newline character is preferred over $NEWLINE_CHAR.
This commit uses \n in configuration options instead of $NEWLINE_CHAR and adds
a final \n to $NEWLINE_CHAR conversion step just prior to sending.