-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
global: workaround Bash 3.2 bug of array initialization with SOH/DEL
- Loading branch information
1 parent
327661f
commit 1720ec0
Showing
6 changed files
with
118 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# bash source | ||
|
||
rex='1..4'; [[ 1444 =~ $rex ]] | ||
declare -p BASH_REMATCH | ||
|
||
function fun1 { | ||
local BASH_REMATCH | ||
declare -p BASH_REMATCH | ||
local rex='1..4' | ||
[[ 1234 =~ $rex ]] | ||
declare -p BASH_REMATCH | ||
} | ||
fun1 | ||
|
||
declare -p BASH_REMATCH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# bash -*- mode: sh; mode: sh-bash -*- | ||
|
||
if ((!_ble_bash)); then | ||
echo 'This script should be sourced into a ble.sh session' >&2 | ||
return 1 | ||
elif ((_ble_bash>=40000)); then | ||
echo 'This source script is for bash 3.X' >&2 | ||
return 1 | ||
fi | ||
|
||
echo '# Check arr2=("${arr1[@]}")' | ||
arr1[0]= | ||
arr1[1]= | ||
arr2=("${arr1[@]}") | ||
ble/util/declare-print-definitions arr1 arr2 | cat -A | ||
echo | ||
|
||
echo '# Check arr1=(1 "$del" "$soh")' | ||
_ble_term_del= | ||
_ble_term_soh= | ||
arr1=(1 "$_ble_term_del" "$_ble_term_soh") | ||
ble/util/declare-print-definitions arr1 | cat -A | ||
echo | ||
|
||
echo '# Check arr1=(2 $del $soh)' | ||
_ble_term_del= | ||
_ble_term_soh= | ||
arr1=(2 $_ble_term_del $_ble_term_soh) | ||
arr2=(2 ''$_ble_term_del'' ''$_ble_term_soh'') | ||
ble/util/declare-print-definitions arr1 arr2 | cat -A | ||
echo | ||
|
||
# 以下は全部駄目。値が変化してしまう。 | ||
echo "# Check arr1=(3 \$'\\001' \$'\\177')" | ||
arr1=(3 $'\001' $'\177') | ||
arr2=(3 ) | ||
arr3=(3 '' '') | ||
ble/util/declare-print-definitions arr1 arr2 arr3 | cat -A | ||
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters