mirror of
https://github.com/sbopkg/sbopkg
synced 2024-12-29 10:24:11 +01:00
Fix an issue with an incompatibility between bash 3.1, 3.2, 4.0 which
caused quoted strings in the RHS of the =~ operator in [[ commands to be interpreted as literal strings, thus causing parts of sbopkg to fail. Update HACKING to address this. Thanks to SiegeX and others for the reports and suggestions. Thanks to Mauro and Chess for review and suggestions.
This commit is contained in:
parent
9405fc1865
commit
51b52b748d
3 changed files with 26 additions and 17 deletions
|
@ -13,4 +13,8 @@ enhancements:
|
||||||
would not work; thanks to happyslacker for the bug report.
|
would not work; thanks to happyslacker for the bug report.
|
||||||
* Add the ability to uninstall SBo packages from the dialog interface that
|
* Add the ability to uninstall SBo packages from the dialog interface that
|
||||||
lists installed packages. Thanks to pokipoki08 for the suggestion.
|
lists installed packages. Thanks to pokipoki08 for the suggestion.
|
||||||
|
* Fix an incompatibility regarding the way bash 3.1, 3.2, and 4.0 handle the
|
||||||
|
RHS of [[ commands using the =~ operator which broke the repo file
|
||||||
|
validation, among other things. Thanks to SiegeX, Zmyrgel, and BCarey for
|
||||||
|
the reports and suggestions.
|
||||||
+--------------------------+
|
+--------------------------+
|
||||||
|
|
|
@ -170,8 +170,8 @@ Please make sure your patches conform to these stylistic points:
|
||||||
echo "Success"
|
echo "Success"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
In the latter case, having 'FGH; then' at the same indent level as the echo is
|
In the latter case, having 'FGH; then' at the same indent level as the echo
|
||||||
ambiguous. On the other hand:
|
is ambiguous. On the other hand:
|
||||||
|
|
||||||
APP=$(grep foo \
|
APP=$(grep foo \
|
||||||
really/long/path/to/file)
|
really/long/path/to/file)
|
||||||
|
@ -223,6 +223,10 @@ Please make sure your patches conform to these stylistic points:
|
||||||
|
|
||||||
if [[ $DIAG ]]; then
|
if [[ $DIAG ]]; then
|
||||||
|
|
||||||
* For indices, use FILE and DIR instead of 'f' and 'd'. However, 'i' is OK as a
|
* For indices, use FILE and DIR instead of 'f' and 'd'. However, 'i' is OK as
|
||||||
counter since that is fairly universal.
|
a counter since that is fairly universal.
|
||||||
|
|
||||||
|
* When deciding whether or not to use the =~ operator in [[ commands, make
|
||||||
|
sure that they work across bash 3.1, 3.2, and 4.0. This means the regexes
|
||||||
|
must be unquoted for bash >=3.2 and still work in bash 3.1 (i.e., no
|
||||||
|
'foo|bar' expressions).
|
||||||
|
|
|
@ -188,8 +188,11 @@ load_repositories() {
|
||||||
eval TMPARRAY=( "$LINE" )
|
eval TMPARRAY=( "$LINE" )
|
||||||
[[ ${#TMPARRAY[@]} -eq 0 ]] && continue;
|
[[ ${#TMPARRAY[@]} -eq 0 ]] && continue;
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
[[ ! ${TMPARRAY[6]} =~ '^GPG$|^$' ]] && ERROR="gpg"
|
# these two assignments work around a bash3-4 incompatibility
|
||||||
[[ ! ${TMPARRAY[4]} =~ '^rsync$|^git$|^$' ]] && ERROR="tool"
|
local GPG='^GPG$|^$'
|
||||||
|
local RSYNC='^rsync$|^git$|^$'
|
||||||
|
[[ ! ${TMPARRAY[6]} =~ $GPG ]] && ERROR="gpg"
|
||||||
|
[[ ! ${TMPARRAY[4]} =~ $RSYNC ]] && ERROR="tool"
|
||||||
[[ ${#TMPARRAY[@]} -ne $REPOS_FIELDS ]] && ERROR="fields"
|
[[ ${#TMPARRAY[@]} -ne $REPOS_FIELDS ]] && ERROR="fields"
|
||||||
[[ -n $ERROR ]] && break 2
|
[[ -n $ERROR ]] && break 2
|
||||||
# Add the record to REPOSITORIES
|
# Add the record to REPOSITORIES
|
||||||
|
@ -1899,7 +1902,7 @@ add_item_to_queue() {
|
||||||
local FILE ONOFF VERSION INSTALLED
|
local FILE ONOFF VERSION INSTALLED
|
||||||
|
|
||||||
# This next if is for legacy queuefiles with $APP $VERSION$BUILD $ONOFF
|
# This next if is for legacy queuefiles with $APP $VERSION$BUILD $ONOFF
|
||||||
if [[ $3 =~ "[Oo][Ff][Ff]" ]]; then
|
if [[ $3 =~ [Oo][Ff][Ff] ]]; then
|
||||||
APP=-$APP
|
APP=-$APP
|
||||||
fi
|
fi
|
||||||
if [[ ${APP:0:1} == "-" ]]; then
|
if [[ ${APP:0:1} == "-" ]]; then
|
||||||
|
@ -2294,14 +2297,12 @@ gen_search_package() {
|
||||||
go back.")" 22 70 14 --file \
|
go back.")" 22 70 14 --file \
|
||||||
$SEARCH_RESULTS 2> $SEARCH_CHOICE
|
$SEARCH_RESULTS 2> $SEARCH_CHOICE
|
||||||
CHOICE=$?
|
CHOICE=$?
|
||||||
if [[ $CHOICE =~ '^(1|255|-1)$' ]]; then
|
case $CHOICE in
|
||||||
# Back or ESC
|
# Back or ESC
|
||||||
break
|
1 | 255 | -1 ) break ;;
|
||||||
elif [[ $CHOICE == 2 ]]; then
|
|
||||||
# Main Menu
|
# Main Menu
|
||||||
RETVAL=1
|
2 ) RETVAL=1; break ;;
|
||||||
break
|
esac
|
||||||
fi
|
|
||||||
SRCHPICK="$(< $SEARCH_CHOICE)"
|
SRCHPICK="$(< $SEARCH_CHOICE)"
|
||||||
if [[ $CATEGORY == '*' ]]; then
|
if [[ $CATEGORY == '*' ]]; then
|
||||||
SRCHCAT="${SRCHPICK%%/*}"
|
SRCHCAT="${SRCHPICK%%/*}"
|
||||||
|
@ -3949,7 +3950,7 @@ main_search() {
|
||||||
SEARCH_TERM=$(< $TERM_FILE)
|
SEARCH_TERM=$(< $TERM_FILE)
|
||||||
# I can't make sure every input makes sense, but I can at least
|
# I can't make sure every input makes sense, but I can at least
|
||||||
# clear out this area of (fairly improbable) glitches
|
# clear out this area of (fairly improbable) glitches
|
||||||
if [[ $SEARCH_TERM =~ "^[\\\.\*\^\$\[\{\(\)\+\?\|]$" ]]; then
|
if [[ $SEARCH_TERM =~ ^[\\\.\*\^\$\[\{\(\)\+\?\|]$ ]]; then
|
||||||
dialog --msgbox "$(crunch "If you are searching for the \
|
dialog --msgbox "$(crunch "If you are searching for the \
|
||||||
literal character '$SEARCH_TERM', then you will need to \
|
literal character '$SEARCH_TERM', then you will need to \
|
||||||
escape it with a backslash like '\\\\$SEARCH_TERM'.\n\nIf\
|
escape it with a backslash like '\\\\$SEARCH_TERM'.\n\nIf\
|
||||||
|
@ -4104,7 +4105,7 @@ if [[ $(id -u) != 0 ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set up ARCH
|
# Set up ARCH
|
||||||
if [[ ! $(uname -m) =~ 'i.86' ]]; then
|
if [[ ! $(uname -m) =~ i.86 ]]; then
|
||||||
export ARCH=${ARCH:-$(uname -m)}
|
export ARCH=${ARCH:-$(uname -m)}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -4260,7 +4261,7 @@ TMPSUMMARYLOG=$SBOPKGTMP/sbopkg-tmp-summarylog
|
||||||
|
|
||||||
# Change $REPO_BRANCH (and optinally REPO_NAME) if set manually using cli -v
|
# Change $REPO_BRANCH (and optinally REPO_NAME) if set manually using cli -v
|
||||||
if [[ $VERSION ]]; then
|
if [[ $VERSION ]]; then
|
||||||
if [[ $CUSTOMVER =~ '.*/.*' ]]; then
|
if [[ $CUSTOMVER =~ .*/.* ]]; then
|
||||||
# The user specified repository/branch
|
# The user specified repository/branch
|
||||||
eval $(sed 's:^\(.*\)/\(.*\)$:REPO_NAME=\1;REPO_BRANCH=\2:g' \
|
eval $(sed 's:^\(.*\)/\(.*\)$:REPO_NAME=\1;REPO_BRANCH=\2:g' \
|
||||||
<<< $CUSTOMVER)
|
<<< $CUSTOMVER)
|
||||||
|
@ -4292,7 +4293,7 @@ directory_checks
|
||||||
pid_check
|
pid_check
|
||||||
|
|
||||||
if [[ $DIAG ]]; then
|
if [[ $DIAG ]]; then
|
||||||
if [[ $TERM =~ "^rxvt.*" || $TERM =~ "^screen.*" ]]; then
|
if [[ $TERM =~ ^rxvt.* || $TERM =~ ^screen.* ]]; then
|
||||||
dialog_refresh_workaround
|
dialog_refresh_workaround
|
||||||
fi
|
fi
|
||||||
main_menu
|
main_menu
|
||||||
|
|
Loading…
Reference in a new issue