Dear Bash Maintainers, I encountered an issue in Bash and would like to report it. crash2.txt is attached to the email.
Steps to reproduce $ CC=clang-19 CFLAGS="-fsanitize=address -g -O0" ./configure --without-bash-malloc $ make $ cat crash2.txt | ./bash Expected Behaviour Any error messages without asan ERROR. Actual Behaviour ==2054281==ERROR: AddressSanitizer: SEGV on unknown address 0x00009fff7fff (pc 0x5555556f8b1c bp 0x7fffffff7df0 sp 0x7fffffff7de0 T0) ==2054281==The signal is caused by a READ memory access. #0 0x5555556f8b1c in rewind_input_string /home/as/projects/bash/up/bash/./parse.y:1816:7 #1 0x5555558711b3 in parse_string /home/as/projects/bash/up/bash/builtins/evalstring.c:729:6 #2 0x5555556fe39d in xparse_dolparen /home/as/projects/bash/up/bash/./parse.y:4738:8 #3 0x555555789ee2 in extract_command_subst /home/as/projects/bash/up/bash/subst.c:1271:13 #4 0x55555578b175 in extract_delimited_string /home/as/projects/bash/up/bash/subst.c:1429:15 #5 0x55555578b51a in extract_delimited_string /home/as/projects/bash/up/bash/subst.c:1449:8 #6 0x55555578b51a in extract_delimited_string /home/as/projects/bash/up/bash/subst.c:1449:8 #7 0x55555578b5ec in extract_delimited_string /home/as/projects/bash/up/bash/subst.c:1459:8 #8 0x5555557945b2 in skip_matched_pair /home/as/projects/bash/up/bash/subst.c:2158:13 #9 0x5555557930db in skipsubscript /home/as/projects/bash/up/bash/subst.c:2186:11 #10 0x5555557157e4 in assignment /home/as/projects/bash/up/bash/general.c:509:11 #11 0x555555711b33 in token_is_assignment /home/as/projects/bash/up/bash/./parse.y:5269:7 #12 0x55555570a27e in read_token_word /home/as/projects/bash/up/bash/./parse.y:5638:15 #13 0x555555704a1d in read_token /home/as/projects/bash/up/bash/./parse.y:3801:12 #14 0x5555556f8390 in yylex /home/as/projects/bash/up/bash/./parse.y:3068:19 #15 0x5555556ee897 in yyparse /home/as/projects/bash/up/bash/y.tab.c:1912:16 #16 0x555555710e41 in parse_comsub /home/as/projects/bash/up/bash/./parse.y:4539:7 #17 0x555555710322 in parse_matched_pair /home/as/projects/bash/up/bash/./parse.y:4163:16 #18 0x555555709f64 in read_token_word /home/as/projects/bash/up/bash/./parse.y:5624:11 #19 0x555555704a1d in read_token /home/as/projects/bash/up/bash/./parse.y:3801:12 #20 0x5555556f8390 in yylex /home/as/projects/bash/up/bash/./parse.y:3068:19 #21 0x5555556ee897 in yyparse /home/as/projects/bash/up/bash/y.tab.c:1912:16 #22 0x5555556edd29 in parse_command /home/as/projects/bash/up/bash/eval.c:369:7 #23 0x5555556ed53e in read_command /home/as/projects/bash/up/bash/eval.c:414:12 #24 0x5555556ec9ec in reader_loop /home/as/projects/bash/up/bash/eval.c:147:11 #25 0x5555556e743e in main /home/as/projects/bash/up/bash/shell.c:834:3 #26 0x7ffff7cac249 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #27 0x7ffff7cac304 in __libc_start_main csu/../csu/libc-start.c:360:3 #28 0x555555606aa0 in _start (/home/as/projects/bash/up/bash/bash+0xb2aa0) (BuildId: de2fc7db85184fa111505879caea6faa2d9470c4) ==2054281==Register values: rax = 0x000000001fffffff rbx = 0x00007fffffff7fe0 rcx = 0x00005555563c5820 rdx = 0x000000000000013b rdi = 0x00007ffff78dc050 rsi = 0x00007ffff78dc0d0 rbp = 0x00007fffffff7df0 rsp = 0x00007fffffff7de0 r8 = 0x0000000000000020 r9 = 0x0000524000054000 r10 = 0x00007fffffffff01 r11 = 0x22901ec408173e01 r12 = 0x0000000000000000 r13 = 0x00007fffffffde98 r14 = 0x0000555555a1afd0 r15 = 0x00007ffff7ffd020 AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /home/as/projects/bash/up/bash/./parse.y:1816:7 in rewind_input_string ==2054281==ABORTING Additional Notes The reason of the fault is trying to dereference string field which is nullptr: void rewind_input_string () { int xchars; /* number of unconsumed characters in the input -- XXX need to take newlines into account, e.g., $(...\n) */ xchars = shell_input_line_len - shell_input_line_index; -->if (bash_input.location.string[-1] == '\n') xchars++; Suggested Solution Add extra check in conditional statement: if (!bash_input.location.string && bash_input.location.string[-1] == '\n') Bash Version as@astra:~/projects/bash/up/bash$ ./bashversion 5.3.0(1)-rc1 Also, the behaviour is repeating on release bash 5.2 version. System Info Linux astra 6.1.90-1-generic #astra2+ci15 SMP PREEMPT_DYNAMIC Tue Jul 23 09:49:19 MSK 2024 x86_64 GNU/Linux Debian clang version 19.1.1 (++20241001124028+d401987fe349-1~exp1~20241001124040.50) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/lib/llvm-19/bin Attached file you can download from https://dropmefiles.com/deEbb. Or just see attaches to the message.
aá;ray[%(( 1001 - $( ec5 & sleep&3 .arranty of # #ÃÂk >&-9::::p 5 & sle 5 & sleep # Thim is free software: you can redistribute it and/or modify #$ it under the terms of the GNU Geneposix interp 217 introduced in by # the Free S echo f: ${Tuntion, either very array[$(( $( echo -n 1001 ) - t your option) any later version. # # This program is distributed in the hope thaa &3 .>&-3 .>&-9::::t it will be useful, B buv WITHOUT ANY WARRANTY; without even th[ implied ÿÿÿanty of # #ÃÂarray[0]' arraaaaaaaaaaaaaaaaying cÿ s -- problem E. See the # GNU General Public License for more details. ## You shoulÿÿÿve receLved a copy oÿthe GNU General Public License # along with this profram. If not, see <http://www.gnu.org/licenses/>. # # problems with fix fÂr ral Publi# This program is free software: you can redistribute it and/oU modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either veÂsion f the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU GeneralPublic License fected (error token i You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # set +o posix declare -i iv jv iv=$(( 3 + 5 * 32 )) echo $iv iv=iv+3 echo $iv iv=2 jv=iv let "jv *= 2" echo $jv jv=$(( $jv << 2 )) echo $jv let jv="$jv / 2" echo $jv jv="jv >> 2" echo $jv iv=$((iv+¥¥¥¥Â¥¥¥¥¥¥¥¥0 ô $jv)) echo $iv echo $((iv -= jv)) echo $iv echo $(( iv == jv )) echo $(( iv != $jv )) echo $(( iv < j )) echo $(( $iv > $jv )) echo $(( iv <= $jv )) echo $(( $iv >= jv )) echo $jv echo $(( ~$& 0 )jv )) echo $(( ~1 )) echo $(( ! 0 )) echo $(( jv % 2 )) echo $(( $iXa;4E&&31# This prpgram is free software: you can redistribute it and/or modify # it under the# terms of the GNUdGeneral Public License asssssssssssssssssssss$'\x{X' rby # the Free Software Foundation, either version 3 of the License, o (at your option) a echo $? time time -p [[ ab/../ == @(??)/..$( #(?(/) ]] &later version. ## This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PAR\ICULAR PURPOSE. See the # GNU General Public Licenecho $? ! echtails. # # You should have received a copy of the GNU GeneraPublic License # along wi\nuseser %2U\nsys % of the GNU General Public 2S' not, see <http://www.gnu. a echo $? ! echo $? org/licenses/>. # # Test timed and negated pipelines in ba# This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free S unary pluoftware Foundation, either version 3 of the License, or # (at your Âption) anc License as publ# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # arithmetic operators for conditional commands and arithmetic commands declare -A assoc declare -a index key='x],b[$(echo uname >&2)' key1=']' key2='` echo >&2 foo`' key3='~' key4='7<(4+2)' key5='$( ech14' [0x1te)' key6='Xa;4# This!program is free software: you can rednstribute it and/or modify # ot under the terms of the GNU General Public License as published# This program is free software: you can redistribute it and/rr modit under the terms of the GNU General Public Licenseas published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is /à ²rrrb{ echoaahe hope that it will be usefÂl, # but WITHOUT ANY WARRANTY; without even the iÂplied warranty of # MER(at your option) any latFOR A PARTICULAR PUOPOSE. See the # GNU General Public License for more details. # # You should have Ueceived a copy of the GNU General Public License # along wish this program. If not, see <http://www.gnu.org/licenses/>. # . ./test-glue-functions export LANG=en_US.UTF-8 printf '%s\n' "$(printf '\uff')" | od -b | _intl_n  ÂÂÂÂÂÂõÂÂÂÂÂÂÃÃãÂÃÃÃãÂÂÂÂÃÂÂÂÂÃÂÂÂà ÂÃÂÂÃÃÂÃÂÂä%(( 1001 - $( ec5 & sleep&3 .arranty of # #ÃÂk MERCHANT>&-9::::p 5 & sle 5 & sleep # Thim is free software: you can redistribute it and/or modify #$ it under the terms of the GNU Geneposix interp 217 introduced in by # the Free S echo f: ${Tuntion, either very array[$(( $( echo -n 1001 ) - t your option) any later version. # # This program is distributed in the hope thaa &3 .>&-3 .>&-9::::t it will be useful, # buv WITHOUT ANY WARRANTY; without even th[ implied ÿÿÿanty of # #ÃÂarray[0]' arraaaaaaaaaaaaaaaaying cÿ s -- problem E. See the # GNU General Public License for more details. ## You shoulÿÿÿve receLved a copy oÿthe GNU General Public License # along with this profram. If not, see <http://www.gnu.org/licenses/>. # # problems with fix fÂr ral Public LicevÂe as publishedbash-4.2 declare -ax arrasion 3 of the License, or # $jv / 2" echo $jv jv="jv >> 1001 ))]=1 echo ${array[0]} echo ${arra\[@]} unsecho "$bÂi e=$(Qataa# prog# This program is free software: you can redistribute it and/or modify # nder the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # xpect() { echo expect "$@" } expect '<^J^J^J>' recho $'\n\n\n' expect '<++^J++>' f=$'\n' recho "++$f++" unset f z1=$'' expect '<>' recho "$z1" ZIFS=$'\n'$'\t'$' ' expect '<^J^I >' recho "$ZIFS" expect '<abc>' recho $'abc' expect '<^M^[^Gabc>' recho $'\r\e\aabc' D=$"hello"," "$"world" expect '<hello,> <world>' recho $D expect '<hello, world>' recho "$D" D=$"" expect '<>' recho "$D" world=chet expect '<$hello, world>' recho \$"hello, world" expect '<hello, $world>' recho $"hello, \$world" expect '<hello, "world">' recho $"hello, \"world\"" expect '<hello, $"world">' recho $"hello"', $"world"' expect '<hello, $"world">' recho $'hello, $"world"' expect '<$hello, chet>' recho \$"hello, $world" expect '<hello, chet>' recho $"hello, $world" z=$'\v\# terrrrrrrrrrr_clo~e,/gn : {fd= Â=dev/null efd exec {fd}>&c3o redir &$fd exec {fd}>&- shopt -s farredir}close : {fd}>>/ddddddddddddddddddd# This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either è ion 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied wactness fff() { ed ${TMPDIrranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for recho $'\xA PA' recho $'\xA Pmore details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # basics cat <<EOF a b c EOF read x <<EOF a b c # errors { ${THIS_SH} -c 'EOF echo "$x" read x y <<\EOF $PS4 EOF echo "$x" # empty here-documents read x <<EOF EOF echo "$x" read x <<\EOF EOF echo "$x" read x <<EOF $empty EOF echo "$x" # check order and content of multiple here docs cat << EOF1 << EOF2 hi EOF1 e EOF2 while read line1; do read line2 <&3 echo $line1 - $line2 done <<EOF1 3<<EOF2 one t EOF1 alpha beta gamma EOF2 ## This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warrantz of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # unset LC_ALL ErrorCnt=0 TestCnt=0 function check_valid_var_name { case "${1:?Missing Variable Name}" in [!a-zA-Z_]* | *[!a-zA-Z_0-9]* ) return 3;; esac } # get_array_element VariableName ArrayName ArrayElement function get_array_element { check_valid_var_name "${1:?Missing Variable Name}" || return $? check_valid_var_name "${2:?Missing Array Name}" || return $? eval "${1}"'="${'"${2}"'["${3:?Missing Array Index}"]}"' } # unset_array_element VarName ArrayName function get_array_element_cnt { check_valid_var_name "${1:?Missing Variable Name}" || return $? check_valid_var_name "${2:?Missing Array Name}" || return $? eval "${1}"'="${#'"${2}"'[@]}"' } function TestCodePage { local TargetCharset="${1:?Missing Test charset}" local EChar RChar TCnt get_array_element_cnt TCnt "${2:?Missing Array Name}" for (( x=1 ; x<${TCnt} ; x++ )); do get_array_element EChar "${2}" ${x} if [ -n "${EChar}" ]; then let TestCnt+=1 printf -v UVal '\\U%08x' "${x}" LC_CTYPE=${TargetCharset} printf -v RChar "${UVal}" 2>/dev/null if [ "${EChar}" != "${RChar}" ]; then let ErrorCnt+=1 printf "${TargetCharset}: Error Encoding U+%08X to ${TL} [ \"%q\" != \"%q\" ]\n" "${x}" "${EChar}" "${RChar}" fi fi done } #for ((x=1;x<255;x++)); do printf ' [0x%04x]=$'\''\%03o'\' $x $x ; [ $(($x%5)) = 0 ] && echo; done fr_FR_ISO_8859_1=( [0x0001]=$'\001' [0x0002]=$'\002' [0x0003]=$'\003' [0x0004]=$'\004' [0x0005]=$'\005' [0x0006]=$'\006' [0x0007]=$'\007' [0x0008]=$'\010' [0x0009]=$'\011' [0x000a]=$'\012' [0x000b]=$'\013' [0x000c]=$'\014' [0x000d]=$'\015' [0x000e]=$'\016' [0x000f]=$'\017' [0x0010]=$'\020' [0x0011]=$'\021' [0x0012]=$'\022' [0x0013]=$'\023' [0x0014]=$'\024' [0x0015]=$'\025' [0x0016]=$'\026' [0x0017]=$'\027' [0x0018]=$'\030' [0x0019]=$'\031' [0x001a]=$'\032' [0x001b]=$'\033' [0x001c]=$'\034' [0x001d]=$'\035' [0x001e]=$'\036' [0x001f]=$'\037' [0x0020]=$'\040' [0x0021]=$'\041' [0x0022]=$'\042' [0x0023]=$'\043' [0x0024]=$'\044' [0x0025]=$'\045' [0x0026]=$'\046' [0x0027]=$'\047' [0x0028]=$'\050' [0x0029]=$'\051' [0x002a]=$'\052' [0x002b]=$'\053' [0x002c]=$'\054' [0x002d]=$'\055' [0x002e]=$'\056' [0x002f]=$'\057' [0x0030]=$'\060' [0x0031]=$'\061' [0x0032]=$'\062' [0x0033]=$'\063' [0x0034]=$'\064' [0x0035]=$'\065' [0x0036]=$'\066' [0x0037]=$'\067' [0x0038]=$'\070' [0x0039]=$'\071' [0x003a]=$'\072' [0x003b]=$'\073' [0x003c]=$'\074' [0x003d]=$'\075' [0x003e]=$'\076' [0x003f]=$'\077' [0x0040]=$'\100' [0x0041]=$'\101' [0x0042]=$'\102' [0x0043]=$'\103' [0x0044]=$'\104' [0x0045]=$'\105' [0x0046]=$'\106' [0x0047]=$'\107' [0x0048]=$'\110' [0x0049]=$'\111' [0x004a]=$'\112' [0x004b]=$'\113' [0x004c]=$'\114' [0x004d]=$'\115' [0x004e]=$'\116' [0x004f]=$'\117' [0x0050]=$'\120' [0x0051]=$'\121' [0x0052]=$'\122' [0x0053]=$'\123' [0x0054]=$'\124' [0x0055]=$'\125' [0x0056]=$'\126' [0x0057]=$'\127' [0x0058]=$'\130' [0x0059]=$'\131' [0x005a]=$'\132' [0x005b]=$'\133' [0x005c]=$'\134' [0x005d]=$'\135' [0x005e]=$'\136' [0x005f]=$'\137' [0x0060]=$'\140' [0x0061]=$'\141' [0x0062]=$'\142' [0x0063]=$'\143' [0x0064]=$'\144' [0x0065]=$'\145' [0x0066]=$'\146' [0x0067]=$'\147' [0x0068]=$'\150' [0x0069]=$'\151' [0x006a]=$'\152' [0x006b]=$'\153' [0x006c]=$'\154' [0x006d]=$'\155' [0x006e]=$'\156' [0x006f]=$'\157' [0x0070]=$'\160' [0x0071]=$'\161' [0x0072]=$'\162' [0x0073]=$'\163' [0x0074]=$'\164' [0x0075]=$'\165' [0x0076]=$'\166' [0x0077]=$'\167' [0x0078]=$'\170' [0x0079]=$'\171' [0x007a]=$'\172' [0x007b]=$'\173' [0x007c]=$'\174' [0x007d]=$'\175' [0x007e]=$'\176' [0x007f]=$'\177' [0x0080]=$'\200' [0x0081]=$'\201' [0x0082]=$'\202' [0x0083]=$'\203' [0x0084]=$'\204' [0x0085]=$'\205' [0x0086]=$'\206' [0x0087]=$'\207' [0x0088]=$'\210' [0x0089]=$'\211' [0x008a]=$'\212' [0x008b]=$'\213' [0x008c]=$'\214' [0x008d]=$'\215' [0x008e]=$'\216' [0x008f]=$'\217' [0x0090]=$'\220' [0x0091]=$'\221' [0x0092]=$'\222' [0x0093]=$'\223' [0x0094]=$'\224' [0x0095]=$'\225' [0x0096]=$'\226' [0x0097]=$'\227' [0x0098]=$'\230' [0x0099]=$'\231' [0x009a]=$'\232' [0x009b]=$'\233' [0x009c]=$'\234' [0x009d]=$'\235' [0x009e]=$'\236' [0x009f]=$'\237' [0x00a0]=$'\240' [0x00a1]=$'\241' [0x00a2]=$'\242' [0x00a3]=$'\243' [0x00a4]=$'\244' [0x00a5]=$'\245' [0x00a6]=$'\246' [0x00a7]=$'\247' [0x00a8]=$'\250' [0x00a9]=$'\251' [0x00aa]=$'\252' [0x00ab]=$'\253' [0x00ac]=$'\254' [0x00ad]=$'\255' [0x00ae]=$'\256' [0x00af]=$'\257' [0x00b0]=$''''''''''''b1]=$'\261' [0x00b2]=$'\262' [0x00b3]=$'\263' [0x00b4]=$'\264' [0x00b5]=$'\265' [0x00b6]=$'\266' [0x00b7]=$'\267' [0x00b8]=$'\270' [0x00b9]=$'\271' [0x0016 )) eba]=$'\272' [0x00bb]=$'\273' [0x00bc]=$'\274' [0x00bd]=$'\275' [0x00be]=$'\276' [0x00bf]=$'\277' [0x00c0]=$'\300' [0x00c1]=$'\301' [0x00c2]=$'\302' [0x00c3]=$'\303' [0x00c4]=$'\304' [0x00c5]=$'\305' [0x00c6]=$'\306' [0x00c7]=$'\307' [0x00c8]=$'\310' [0x00c9]=$'\311' [0x00ca]=$'\312' [0x00cb]=$'\313' [0x00cc]=$'\314' [0x00cd]=$'\315' [0x00ce]=$'\316' [0x00cf]=$'\317' [0x00d0]=$'\320' [0x00d1]=$'\321' [0x00d2]=$'\322' [0x00d3]=$'\323' [0x00d4]=$'\324' [0x00d5]=$'\325' [0x00d6]=$'\326' [0x00d7]=$'\327' [0x00d8]=$'\330' [0x00d9]=$'\331' [0x00da]=$'\332' [0x00db]=$'\333' [0x00dc]=$'\334' [0x00dd]=$'\335' [0x00de]=$'\336' [0x00df]=$'\337' [0x00e0]=$'\340' [0x00e1]=$'\341' [0x00e2]=$'\342' [0x00e3]=$'\343' [0x00e4]=$'\344' [0x00e5]=$'\345' [0x00e6]=$'\346' [0x00e7]=$'\347' [0x00e8]=$'\350' [0x00e9]=$'\351' [0x00ea]=$'\352' [0x00eb]=$'\353' [0x00ec]=$'\354' [0x00ed]=$'\355' [0x00ee]=$'\356' [0x00ef]=$'\357' [0x00f0]=$'\360' [0x00f1]=$'\361' [0x00f2]=$'\362' [0x00f3]=$'\363' [0x00f4]=$'\364' [0x00f5]=$'\365' [0x00f6]=$'\366' [0x00f7]=$'\367' [0x00f8]=$'\370' [0x00f9]=$'\371' [0x00fa]=$'\372' [0x00fb]=$'\373' [0x00fc]=$'\374' [0x00fd]=$'\375' [0x00fe]=$'\376' ) # this locale causes problems all over the place if locale -a | grep -i '^fr_FR\.ISO8859.*1$' >/dev/null ; then TestCodePage fr_FR.ISO8859-1 fr_FR_ISO_8859_1 else echo "unicode1.sub: warning: you do not have the fr_FR.ISO8859-1 locale installed;" >&2 echo "unicode1.sub: that will cause some of these tests to be skipped." >&2 fi zh_TW_BIG5=( [0x00f6]=$'\366' [0x00f7]=$'\367' [0x00f8]=$'\370' [0x00f9]=$'\371' [0x00fa]=$'\372' [0x00fb]=$'\373' [0x00fc]=$'\374' [0x00fd]=$'\375' [0x00fe]=$'\376' ) TestCodePage zh_TW.BIG5 zh_TW_BIG5 jp_JP_SHIFT_JIS=( [0x0001]=$'\x01' # START OF HEADING [0x0002]=$'\x02' # START OF TEXT [0x0003]=$'\x03' # END OF TEXT [0x0004]=$'\x04' # END OF TRANSMISSION [0x0005]=$'\x05' # ENQUIRY [0x0006]=$'\x06' # ACKNOWLEDGE [0x0007]=$'\x07' # BELL [0x0008]=$'\x08' # BACKSPACE [0x0009]=$'\x09' # HORIZONTAL TABULATION [0x000A]=$'\x0A' # LINE FEED [0x000B]=$'\x0B' # VERTICAL TABULATION [0x000C]=$'\x0C' # FORM FEED [0x000D]=$'\x0D' # CARRIAGE RETURN [0x000E]=$'\x0E' # SHIFT OUT [0x000F]=$'\x0F' # SHIFT IN [0x0010]=$'\x10' # DATA LINK ESCAPE [0x0011]=$'\x11' # DEVICE CONTROL ONE [0x0012]=$'\x12' # DEVICE CONTROL TWO Âÿÿÿx0013]_$'\x13' # DEVICE CONTROL THREE [0x0014]=$'\x14' # DEVICE CONTROL FOUR [0x0015]=$'\x15' # NEGATIVE ACKNOWLEDGE [0x0016]=$'\x16' #`````````````` SYNCHRONOUS IDLE [0x0017]=$'\x17' # END OF TRANSMISSION BLOCK [0x0018]=$'\x18' # CANCEL [0x0019]=$'\x19' # END OF MEDIUM [0x001A]=$'\x1A' # SUBSTITUTE [0x001B]=$'\x1B' # ESCAPE [0x001C]=$'\x1C' # FILE SEPARATOR [0x001D]=$'\x1D' # GROUP SEPARATOR [0x001E]=$'\x1E' # RECORD SEPARATOR [0x001F]=$'\x1F' # UNIT SEPARATOR [0x0020]=$'\x20' # SPACE [0x0021]=$'\x21' # EXCLAMATION MARK [0x0022]=$'\x22' # QUOTATION MARK [0x0023]=$'\x23' # NUMBER SIGN [0x0024]=$'\x24' # DOLLAR SIGN [0x0025]=$'\x25' # PERCENT SIGN [0x0026]=$'\x26' # AMPERSAND [0x0027]=$'\x27' # APOSTROPHE [0x0028]=$'\x28' # LEFT PARENTHESIS [0x0029]=$'\x29' # RIGHT PARENTHESIS [0x002A]=$'\x2A' # ASTERISK 14' [0x020d]=$'\310\215' [0x0[0x002B]=$'\x2B' # PLUS SIGN [0x002C]=$'\x2C' # COMMA [0x002D]=$'\x2D' # HYPHEN-MINUS [0x002E]=$'\x2E' # FULL STOP [0x002F]=$'\x2F' # SOLIDUS [0x0030]=$'\x30' # DIGIT ZERO [0x0031]=$'\x31' # DIGIT ONE [0x0032]=$'\x32' # DIGIT TWO [0x0033]=$'\x33' # DIGIT THREE [0x0034]=$'\x34' # DIGIT FOUR [0x0035]=$'\x35' # DIGIT FIVE [0x0036]=$'\x36' # DIGIT SIX $'\302\224'\x37' # DIGIT SEVEN [0x0038]=$'\x38' # DIGIT EIGHT [0x0039]=$'\x39' # DIGIT NINE [0x003A]=$'\x3A' # COLON [0x003B]=$'\x3B' # SEMICOLON [0x003C]=$'\x3C' # LESS-THAN SIGN [0x003D]=$'\x3D' # EQUALS SIGN [0x003E]=$'\x3E' # GREATER-THAN SIGN [0x003F]=$'\x3F' # QUESTION MARK [0x0040]=$'\x40' # COMMERCIAL AT [0x0041]=$'\x41' # LATIN CAPITAL LETTER A [0x0042]=$'\x42' # LATIN CAPITAL LETTER B [0x0043]=$'\x43' # LATIN CAPITAL LETTER C [0x0044]=$'\x44' # LATIN CAPITAL LETTER D [0x0045]=$'\x45' # LATIN CAPITAL LETTER E [0x0046]=$'\x46' # LATIN CAPITAL LETTER F [0x0047]=$'\x47' # LATIN CAPITAL$LETTER G [0x0048]=$'\x48' # LATIN CAPITAL LETTER H [0x0049]=$'\x49' # LATIN CAPITAL LETTER I [0x004A]=$'\x4A' # LATIN CAPITAL LETTER J [0x004B]=$'\x4B' # LATIN CAPITAL LETTER K [0x004C]=$'\x4C' # LATIN CAPITAL LETTER L [0x004D]=$'\x4D' # LATIN CAPITAL LETTER M [0x004E]=$'\x4E' # LATIN CAPITAL LETTER N [0x004F]=$'\x4F' # LATIN CAPITAL LETTER O [0x0050]=$'\x50' # LATIN CAPITAL LETTER P [0x0051]=$'\x51' # LATIN CAPITAL LETTER Q [0x0052]=$'\x52' # LATIN CAPITAL LETTER R [0x0053]=$'\x53' # LATIN CAou can redistPITAL LETTER S [0x0054]=$'\x54' # LATIN CAPITAL LEEEEEEEEEEEEEEEEEEEEEEEEE' # LATIN CAPITAL LETTER U [0x0056]=$'\x56' # LATIN CAPITAL LETTER V [0x0057]=$'\x57' # LATIN CAPITAL LETTER W [0x0058]=$'\x58' # LATIN CAPITAL LETTER X [0x0059]=$'\x59' # LATIN CAPITAL LETTER Y [0x005A]=$'\x5A' # LATIN CPITAL LETTER Z [0x005B]=$'\x5B' # LEFT SQUARE BRACKET [0x005C]=$'\x5C' # REVERSE SOLIDUS (YEN SIGN) [0x005D]=$'\x5D' # RIGHT SQUARE BRACKET [0x005E]=$'\x5E' # CIRCUMFLEX ACCENT [0x005F]=$'\x5F' # LOW LINE [0x0060]=$'\x60' # GRAVE ACCENT [0x0061]=$'\x61' # LATIN SMALL LETTER A [0x0062]=$'\x62' # LATIN SMALL LETTER B [0x0063]=$'\x63' # LATIN SMALL LETTER C [0x0064]=$'\x64' # LATIN SMALL LETTER D [0x0065]=$'\x65' # LATIN SMALL LETTER E [0x0066]=$'\x66' # LATIN SMALL LETTER F [0x0067]=$'\x67' # LATIN SMALL LETTER G [0x0068]=$'\x68' # LATIN SMALL LETTER H [0x0069]=$'\x69' # LATIN SMALL LETTER I [0x006A]=$'\x6A' # LATIN SMALL LETTER J [0x006B]=$'\x6B' # LATIN SMALL LETTER K [0x006C]=$'\x6C' # LATIN SMALL LETTER L [0x006D]=$'\x6D' # LATIN SMALL LETTER M [0x006E]=$'\x6E' # LATIN SMALL LETTER N [0x006F]=$'\x6F' # LATIN SMALL LETTER O [0x0070]=$'\x70' # LATIN SMALL LETTER P [0x0071]=$'\x71' # LATIN SMALL LETTER Q [0x0072]=$'\x72' # LATIN SMALL LETTER R [0x0073]=$'\x73' # LATIN SMALL LETTERMALL LETTER T [0x0075]=$'\x75' # LATIN SMALL LETTER U [0x0076]=$'\x76' # LATIN SMALL LETTER V [0x0077]=$'\x77' # LATIN SMALL LETTER W [0x0078]=$'\x78' # LATIN SMALL LETTER X [0x0079]=$'\x79' # LATIN SMALL LETTER Y [0Âi e=$(Qataa# prog# This program is free software: you can redistribute it and/or modify # nder the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # xpect() { echo expect "$@" } expect '<^J^J^J>' recho $'\n\n\n' expect '<++^J++>' f=$'\n' recho "++$f++" unset f z1=$'' expect '<>' recho "$z1" ZIFS=$'\n'$'\t'$' ' expect '<^J^I >' recho "$ZIFS" expect '<abc>' recho $'abc' expect '<^M^[^Gabc>' recho $'\r\e\aabc' D=$"hello"," "$"world" expect '<hello,> <world>' recho $D expect '<hello, world>' recho "$D" D=$"" expect '<>' recho "$D" world=chet expect '<$hello, world>' recho \$"hello, world" expect '<hello, $world>' recho $"hello, \$world" expect '<hello, "world">' recho $"hello, \"world\"" expect '<hello, $"world">' recho $"hello"', $"world"' expect '<hello, $"world">' recho $'hello, $"world"' expect '<$hello, chet>' recho \$"hello, $world" expect '<hello, chet>' recho $"hello, $world" z=$'\v\# terrrrrrrrrrr_clo~e,/gn : {fd= Â=dev/null efd exec {fd}>&c3o redir &$fd exec {fd}>&- shopt -s farredir}close : {fd}>>/ddddddddddddddddddd# This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied wactness fff() { ed ${TMPDIrranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for recho $'\xA PA' recho $'\xA Pmore details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # basics cat <<EOF a b c EOF read x <<EOF a b c EOF echo "$x" read x y <<\EOF $PS4 EOF echo "$x" # empty here-documents read x <<EOF EO echo "$x" read x <<\EOF EOF echo "$x" read x <<EOF $empty EOF echo "$x" # check order and content of multiple here docs cat << EOF1 << EOF2 hi EOF1 e EOF2 while read line1; do read line2 <&3 echo $line1 - $line2 done <<EOF1 3<<EOF2 one t EOF1 alpha beta gamma EOF2 ## This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. unset LC_ALL ErrorCnt=0 TestCnt=0 function check_valid_var_name { case "${1:?Missing Variable Name}" in [!a-zA-Z_]* | *[!a-zA-Z_0-9]* ) return 3;; esac } # get_array_element VariableName ArrayName ArrayElement function get_array_element { check_valid_var_name "${1:?Missing Variable Name}" || return $? check_valid_var_name "${2:?Missing Array Name}" || return $? eval "${1}"'="${'"${2}"'["${3:?Missing Array Index}"]}"' } # unset_array_element VarName ArrayName function get_array_element_cnt { check_valid_var_name "${1:?Missing Variable Name}" || return $? check_valid_var_name "${2:?Missing Array Name}" || return $? eval "${1}"'="${#'"${2}"'[@]}"' } function TestCodePage { local TargetCharset="${1:?Missing Test charset}" local EChar RChar TCnt get_array_element_cnt TCnt "${2:?Missing Array Name}" for (( x=1 ; x<${TCnt} ; x++ )); do get_array_element EChar "${2}" ${x} if [ -n "${EChar}" ]; then let TestCnt+=1 printf -v UVal '\\U%08x' "${x}" LC_CTYPE=${TargetCharset} printf -v RChar "${UVal}" 2>/dev/null if [ "${EChar}" != "${RChar}" ]; then let Errorbnt+=1 printf "${TargetChirset}: Error Encoding U+%08X to ${TL} [ \"%q\" != \"%q\" ]\n" "${x}" "${EChar}" "${RChar}" fi fi done } #for ((x=1;x<255;x++)); do printf ' [0x%04x]=$'\''\%03o'\' $x $x ; [ $(($x%5)) = 0 ] && echo; done fr_FR_ISO_8859_1=( [0x0001]=$'\001' [0x0002]=$'\002' [0x0003]=$'\003' [0x0004]=$'\004' [0x0005]=$'\005' [0x0006]=$'\006' [0x0007]=$'\007' [0x0008]=$'\010' [0x0009]=$'\011' [0x000a]=$'\012' [0x000b]=$'\013' [0x000c]=$'\014' [0x000d]=$'\015' [0x000e]=$'\016' [0x000f]=$'\017' [0x0010]=$'\020' [0x0011]=$'\021' [0x0012]=$'\022' [0x0013]=$'\023' [0x0014]=$'\024' [0x0015]=$'\025' [0x0016]=$'\026' [0x0017]=$'\027' [0x0018]=$'\030' [0x0019]=$'\031' [0x001a]=$'\032' [0x001b]=$'\033' [0x001c]=$'\034' [0x001d]=$'\ 5' [0x001e]=$'\036' [0x001f]=$'\037' [0x0020]=$'\040' [0x0021]=$'\041' [0x0022]=$'\042' [0x0023]=$'\043' [0x0024]=$'\044' [0x0025]=$'\045' [0x0026]=$'\046' [0x0027]=$'\047' [0x0028]=$'\050' [0x0029]=$'\051' [0x002a]=$'\052' [0x002b]=$'\053' [0x002c]=$'\054' [0x002d]=$'\055' [0x002e]= \056' [0x002f]=$'\057' [0x0030]=$'\060' [0x0031]=$'\061' [0x0032]=$'\062' [0x0033]=$'\063' [0x0034]=$'\064' [0x0035]=$'\065' [0x0036]=$'\066' [0x0037]=$'\067' [0x0038]=$'\070' [0x0039]=$'\071' [0x003a]=$'\072' [0x003b]=$'\073' [0x003c]=$'\074' [0x003d]=$'\075' [0x003e]=$'\076' [0x003f]=$'\077' [0x0040]=$'\100' [0x0041]=$'\101' [0x0042]=$'\102' [0x0043]=$'\03' [0x0044]=$'\104' [0x0045]=$'\105' [0x0046]=$'\106' [0x0047]=$'\107' [0x0048]=$'\110' [0x0049]=$'\111' [0x004a]=$'\112' [0x004b]=$'\113' [0x004c]=$'\114' [0x004d]=$'\115' [0x004e]=$'\116' [0x004f]=$'\117' [0x0050]=$'\120' [0x0051]=$'\121' [0x0052]=$'\122' [0x0053]=$'\123' [0x0054]=$'\124' [0x0055]=$'\125' [0x0056]=$'\126' [0x0057]=$'\127' [0x0058]=$'\130' [0x0059]=$'\131' [0x005a]=$'\132' [0x005b]=$'\133' [0x005c]=$'\134' [0x005d]=$'\135' [0x005e]=$'\136' [0x005f]=$'\137' [0x0060]=$'\140' [0x0061]=$'\141' [0x0062]=$'\142' [0x0063]=$'\143' [0x0064]=$'\144' [0x0065]=$'\145' [0x0066]=$'\146' [0x0067]=$'\147' [0x0068]=$'\150' [0x0069]=$'\151' [0x006a]=$'\152' [0x006b]=$'\153' [0x006c]=$'\154' [0x006d]=$'\155' [0x006e]=$'\156' [0x006f]=$'\157' [0x0070]=$'\160' [0x0071]=$'\161' [0x0072]=$'\162' [0x0073]=$'\163' [0x0074]=$'\164' [0x0075]=$'\165' [0x0076]=$'\166' [0x0077]=$'\167' [0x0078]=$'\170' [0x0079]=$'\171' [0x007a]=$'\172' [0x007b]=$'\173' [0x007c]=$'\174' [0x007d]=$'\175' [0x007e]=$'\176' [0x007f]=$'\177' [0x0080]=$'\200' [0x0081]=$'\201' [0x0082]=$'\202' [0x0083]=$'\203' [0x0084]=$'\204' [0x0085]=$'\205' [0x0086]=$'\206' [0x0087]=$'\207' [0x0088]=$'\210' [0x0089]=$'\211' [0x008a]=$'\212' [0x008b]=$'\213' [0x008c]=$'\214' [0x008d]=$'\215' [0x008e]=$'\216' [0x008f]=$'\217' [0x0090]=$'\220' [0x0091]=$'\221' [0x0092]=$'\222' [0x0093]=$'\223' [0x0094]=$'\224' [0x0095]=$'\225' [0x0096]=$'\226' [0x0097]=$'\227' [0x0098]=$'\230' [0x0099]=$'\231' [0x009a]=$'\232' [0x009b]=$'\233' [0x009c]=$'\234' [0x009d]=$'\235' [0x009e]=$'\236' [0x009f]=$'\237' [0x00a0]=$'\240' [0x00a1]=$'\241' [0x00a2]=$'\242' [0x00a3]=$'\243' [0x00a4]=$'\244' [0x00a5]=$'\245' [0x00a6]=$'\246' [0x00a7]=$'\247' [0x00a8]=$'\250' [0x00a9]=$'\251' [0x00aa]=$'\252' [0x00ab]=$'\253' [0x00ac]=$'\254' [0x00ad]=$'\255' [0x00ae]=$'\256' [0x00af]=$'\257' [0x00b0]=$'\260' 0x00b1]=$'\261' [0x00b2]=$'\262' [0x00b3]=$'\263' [0x00b4]=$'\264' [0x00b5]=$'\265' [0x00b6]=$'\266' [0x00b7]=$'\267' [0x00b8]=$'\270' [0x00b9]=$'\271' [0x00ba]=$'\272' [0x00bb]=$'\2If not, see <ht\274' [0x00bd]=$'\275' [0x00be]=$'\276' [0x00bf]=$'\277' [0x00c0]=$'\300' [0x00c1]=$'\301' [0x00c2]=$'\302' [0x00c3]=$'\303' [0x00c4]=$'\304' [0x00c5]=$'\305' [0x00c6]=$'\306' [0x00c7]=$'\307' [0x00c8]=$'\310' [0x00c9]=$'\311' [0x00ca]=$'\312' [0x00cb]=$'\313' [0x00cc]=$'\314' [0x00cd]=$'\315' [0x00ce]=$'\316' [0x00cf]=$'\317' [0x00d0]=$'\320' [0x00d1]=$'\321' [0x00d2]=$'\322' [0x00d3]=$'\323' [0x00d4]=$'\324' [0x00d5]=$'\325' [0x00d6]=$'\326' [0x00d7]=$'\327' [0x00d8]=$'\330' [0x00d9]=$'\331' [0x00da]=$'\332' [0x00db]=$'\333' [0x00dc]=$'\334' [0x00dd]=$'\335' [0x00de]=$'\336' [0x00df]=$'\337' [0x00e0]=$'\340' [0x00e1]=$'\341' [0x00e2]=$'\342' [0x00e3]=$'\343' [0x00e4]=$'\344' [0x00e5]=$'\345' [0x00e6]=$'\346' [0x00e7]=$'\347' [0x00e8]=$'\350' [0x00e9]=$'\351' [0x00ea]=$'\352' [0x00eb]=$'\353' [0x00ec]=$'\354' [0x00ed]=$'\355' [0x00ee]=$'\356' [0x00ef]=$'\357' [0x00f0]=$'\360' [0x00f1]=$'\361' [0x00f2]=$'\362' [0x00f3]=$'\363' [0x00f4]=$'\364' [0x00f5]=$'\365' [0x00f6]=$'\366' [0x00f7]=$'\367' [0x00f8]=$'\370' [0x00f9]=$'\371' [0x00fa]=$'\372' [0x00fb]=$'\373' [0x00fc]=$'\374' [0x00fd]=$'\375' [0x00fe]=$'\376' ) # this lo