-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bash 2.05a compatibility #70
Conversation
The earliest bash version with which Pnut can bootstrap itself is 2.05b. Version 2.05a fails when pnut gets to the end of an #included file because free is called and the `unset` builtin fails (and then pnut because of set -e). We already have an option that toggle free between a no-op and using unset, so let's disable it since it doesn't make much of a difference for pnut. From bash's `CHANGES` file: h. The `unset' builtin no longer returns a failure status when asked to unset a previously-unset variable or function.
eeddcb8
to
e1bf6c1
Compare
5df6b4e
to
982bcce
Compare
982bcce
to
85ce06a
Compare
brew install coreutils | ||
else | ||
sudo apt-get update | ||
sudo apt-get install -y coreutils |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timeout
utility lives in coreutils
. It's usually preinstalled but let's just make sure it is.
@@ -4,8 +4,10 @@ set -e -u | |||
|
|||
TEMP_DIR="bootstrap-results" | |||
|
|||
PNUT_EXE_OPTIONS= # Set by the backend option | |||
PNUT_SH_OPTIONS="-DRT_NO_INIT_GLOBALS -Dsh" | |||
: ${PNUT_OPTIONS:=} # Default to empty options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bootstrap-pnut*.sh
and run-tests.sh
scripts now passes the PNUT_OPTIONS
environment to pnut. This allows us to enable certain options (by defining macros) from outside the script.
@@ -46,7 +46,7 @@ unpack_escaped_string() { | |||
__buf="${__buf#?}" # Remove the current char from $__buf | |||
;; | |||
*) | |||
__c=$(LC_CTYPE=C printf "%d" "'${__buf%"${__buf#?}"}") | |||
__c=$(LC_CTYPE=C printf "%d" "'${__buf%"${__buf#?}"}"); __c=$((__c > 0 ? __c : 256 + __c)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bash-2.05a uses signed char
so everything in the extended range gets encoded as a negative number. We could remove this line if we choose to not support early versions of bash, but it worth the extract few characters so we can say we support a version of bash from 2001.
if [ "$backend" = "sh" ]; then | ||
bash "./$1" $2 # Default to bash for sh backend | ||
# Use a 30s timeout to prevent infinite loops | ||
timeout ${2:-30} $shell "./$1" $3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script used to ignore the --shell
option and would always use bash. I fixed the issue, but this meant I had to disable a failing few tests for yash
.
fed3a17
to
85ce06a
Compare
Context
In #69, it looked like compatibility with bash version 1.14 was easily attainable. Unfortunately, the workaround to emit characters using
%b
doesn't work for\0
meaning more work is required to bootstrappnut-exe
usingpnut.sh
on bash 1.14.This PR makes pnut compatible with bash version 2.05a, and adds the necessary CI checks to ensure we don't break compatibility by accident. The main problem was with
unset
which fails when unsetting a variable that was not set. This bug was fixed in version 2.05b, explaining why version 2.05a was failing but not 2.05b. Fortunately,unset
is only used in thefree
function which is not important to Pnut and is only called in 1 place and the existingRT_FREE_UNSETS_VARS
macro controls the behavior offree
(unset vs no-op).