14.1 Quoted characters

Function: mbfl_string_is_quoted_char STRING POSITION

Return true if the character at POSITION in STRING is quoted; else return false. A character is considered quoted if it is preceded by an odd number of backslashes (\). POSITION is a zero–based index.

mbfl_string_is_quoted_char 'abcdefg'  3 ;$? ⇒ 1
mbfl_string_is_quoted_char 'ab\cdefg' 3 ;$? ⇒ 0
mbfl_string_is_quoted_char 'ab\ndefg' 3 ;$? ⇒ 0
Function: mbfl_string_is_equal_unquoted_char STRING POSITION CHAR

Return true if the character at POSITION in STRING is equal to CHAR and is not quoted (according to mbfl_string_is_quoted_char()); else return false. POSITION is a zero–based index.

mbfl_string_is_equal_unquoted_char abcdefg 3 d
;$? ⇒ 0

mbfl_string_is_equal_unquoted_char 'abc\defg' 3 d
;$? ⇒ 1
Function: mbfl_string_quote STRING
Function: mbfl_string_quote_var _RV STRING

Print STRING with quoted characters. All the occurrences of the backslash character, \, are substituted with a quoted backslash, \\. Return true.

The function variant _var stores the result in the variable _RV, rather than print it; Result variables.

mbfl_string_quote \\a\\b\\c     -| \\\\a\\\\b\\\\c
mbfl_string_quote abc           -| abc
mbfl_string_quote "a b\tc\n\r"  -| a\ b\\\\tc\\\\n\\\\r

local _RV
mbfl_string_quote_var _RV \\a\\b\\c
"$_RV"   ⇒ \\\\a\\\\b\\\\c

This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.