udem-dlteam/pnut

Documentation for supported shell versions

Opened this issue · 5 comments

I've being playing around with pnut on various versions of bash/ksh. I have found that with very old versions pnut.sh will error out (versions from the 90s). With fairly old versions of bash/ksh (early 2000s like bash 2.05) they often work so far, but stop compiling pnut.c part way through. I'm assuming I'm hitting some internal limits within the shell. The earliest version of ksh I have had success with is ksh93u-20120801. I managed to build that version of ksh on an old slackware-8.1 vm.

Interesting! We've wanted to test on older versions of shells but never got to it so we mostly supposed it worked.

I just tested with versions 3.1 and 2.05b of bash (compiled and run on a Ubuntu 22.04.4 VM) and it seems to be working:

$ ./bootstrap-pnut.sh --shell "../bash-3.1/bash"
Bootstrap with ../bash-3.1/bash
4977.24user 5.52system 1:29:10elapsed 93%CPU (0avgtext+0avgdata 47104maxresident)k
0inputs+455outputs (0major+11225minor)pagefaults 0swaps
  3227  10471  80067 pnut.c
  7240  32486 233360 bootstrap-results/pnut.sh
  7240  32486 233360 bootstrap-results/pnut-twice-bootstrapped.sh
 17707  75443 546787 total

It took a long time, around 1h30 (on a M1 Macbook Pro) on both versions, and seemed to slow down as it progressed, so it's possible it looked stuck but wasn't actually stuck?

I'll try on bash-1.14.7 and ksh93u later, and will update the README accordingly.

Turns out the issue occurs with bash 2.05a but not 2.05b (Slackware 8.1 is on 2.05a). With 2.05a it stops compiling pnut.sh about half way through. Up to that point the code output is identical. It just stops with an exit code of 1 and no error message.

The issue can be reproduced in a debian woody debootstrap chroot.

I generated the chroot with this command:

sudo debootstrap --arch=i386 woody woody

On woody (bash 2.05a) the same issue occurs.
On debian sarge (bash 2.05b) pnut.sh works fine and runs to completion.

On bash 1.14 (slackware 2.0.0) I get the following error:

darkstar:~/pnut# bash bootstrap-results/pnut.sh
Usage: printf: \1: invalid escape

The behaviour of printf seems to be different:

darkstar:~/pnut# printf "\110\n"
printf: \1: invalid escape
darkstar:~/pnut# printf "\0110\n"
H

Unfortunately that 4 digit octal notation doesn't work correctly on modern printf (eg on Ubuntu 22.04):

$ printf "\0110\n"
	0

A way that seems to work consistently is using %b:

darkstar:~/pnut# printf "%b" "\0110\n"
H
$ printf "%b" "\0110\n"
H

The debootstrap script was very useful and I was able to reproduce the issue with version 2.05a. This commit fixes the issue, and it was the only thing preventing Pnut from bootstrap on that version.

For version 1 of bash, I haven't had time to setup a slackware VM to test it. I did make the changes to how characters are emitted by Pnut, maybe you can test it if you have time?

Both changes live on laurent/bash-1-compatibility (See PR: #69)

Seems to be a bit of a pain to build bash 1.14 on a more modern distro.

On my slackware 2.0.0 VM I am getting this error on the lastest version from main

darkstar:~/pnut# cat log
bash bootstrap-results/pnut.sh -DRT_NO_INIT_GLOBALS -Dsh pnut.c
darkstar:~/pnut# bash bootstrap-results/pnut.sh -DRT_NO_INIT_GLOBALS -Dsh pnut.c
#!/bin/sh
set -e -u

(_max_text_alloc > _text_alloc) ? _max_text_alloc: _text_alloc: syntax error in expression (remainder of expression is "_max_text_alloc: _text_alloc")

Bash 1.x seems not to support ?: