The purpose of this module is to let an external process invoke a Bash script with damned
command line arguments: strings including blanks or strange characters that may trigger quoting
rules. This problem can arise when using scripting languages with some sort of eval
command.
The solution is to encode the argument string in hexadecimal or octal format strings, so that all the damned characters are converted to “good” ones. The Bash script can convert them back.
NOTE Internally Bash represents strings as C language style ASCIIZ arrays, so it is impossible to correctly handle null bytes in a Bash variable: the string will get truncated at the null byte.
Encode a hex string and outputs it on stdout
.
The function variant _var
stores the result in the variable _RV, rather than print it;
Result variables.
Decode a hex string and outputs it on stdout
.
The function variant _var
stores the result in the variable _RV, rather than print it;
Result variables.
Decode a oct string and outputs it on stdout
.
The function variant _var
stores the result in the variable _RV, rather than print it;
Result variables.
Example:
mbfl_decode_hex 414243 -| ABC
This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.