comparison tests/farray-array.t @ 635:2d0201f54870

farray.sh: Also provide a strict posixly correct quoting alternative. Because $'...' is not a POSIX standard supply now the possibility to encode using just single quotes (without dollar): this is posixly correct. More quoting tests.
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 26 Sep 2024 11:58:44 +0200
parents 618f8e72e5e6
children 57ee25cec0dd
comparison
equal deleted inserted replaced
634:618f8e72e5e6 635:2d0201f54870
904 904
905 $ farray_destroy TEST 905 $ farray_destroy TEST
906 $ check_no_array_artifacts 906 $ check_no_array_artifacts
907 907
908 908
909 Eval 909 Eval / Quoting
910 ==== 910 ==============
911 911
912 $ _var=$'" 678" \\\'910 ' 912 # Use Dollar-Single-Quotes
913 $ eval _evar="\$(_farr_quote_for_eval \"\${_var}\")" 913 $ _var1=$'" 678" \\\'910 '
914 # Use just Single-Quotes
915 $ _var2='" 678" \'\''910 '
916 # Use a Double-Quotes to insert a single quote
917 $ _var3='" 678" \'"'"'910 '
918 $ test "${_var1}" = "${_var2}"
919 $ test "${_var1}" = "${_var3}"
920 $ eval _evar="\$(_farr_quote_for_eval \"\${_var1}\")"
914 $ eval printf '%s' "${_evar}" 921 $ eval printf '%s' "${_evar}"
915 " 678" \'910 (no-eol) 922 " 678" \'910 (no-eol)
916 $ _var=$'" 678" \\\'910\t\'' 923 $ _var1=$'" 678" \\\'910\t\''
917 $ eval _evar="\$(_farr_quote_for_eval \"\${_var}\")" 924 $ _var2='" 678" \'\''910 '\'''
925 $ _var3='" 678" \'"'"'910 '"'"''
926 $ test "${_var1}" = "${_var2}"
927 $ test "${_var1}" = "${_var3}"
928 $ eval _evar="\$(_farr_quote_for_eval \"\${_var1}\")"
929 $ eval printf '%s' "${_evar}"
930 " 678" \'910 ' (no-eol)
931 $ _var1=$'" 678" \\\'910\t\''
932 $ eval _evar="\$(_farr_quote_for_eval_strict \"\${_var1}\")"
918 $ eval printf '%s' "${_evar}" 933 $ eval printf '%s' "${_evar}"
919 " 678" \'910 ' (no-eol) 934 " 678" \'910 ' (no-eol)
920 935
921 936
922 Join 937 Join