Fixes in 1990/jaw
The program (and the generated program made by shark.sh) no longer use perror(3) and instead use fprintf(3) (writing to stderr). This is mostly because in macOS errno == 0 looks like an error. Some updates to the shark.sh script were also made. The bug status has been updated as there is apparently another bug though I was sure it was solved when I last looked at it. It happens with and without the above updates. I'm unsure about other things too but these are not in the bugs.md yet as I'm not even sure what to say just yet. Added try.sh script which does some of the commands. However as there is that bug it doesn't do any comparisons - for now.
This commit is contained in:
1 parent
1df3b50b23
commit
1d6ef234d0
7 files changed
+35
-53
No files matched your search
+1
-1
@@ -67,7 +67,7 @@ CINCLUDE=
|
||||
|
||||
# Optimization
|
||||
#
|
||||
OPT= -O3
|
||||
OPT=
|
||||
|
||||
# Default flags for ANSI C compilation
|
||||
#
|
||||
|
||||
+4
-4
@@ -67,7 +67,7 @@ shark.sh, contains a 'jaw.c' embedded within it!
|
||||
The sender must have `compress` and `btoa`. To send, try:
|
||||
|
||||
```sh
|
||||
sh shark.sh jaw.* README.md > receive
|
||||
./shark.sh jaw.* README.md > receive
|
||||
```
|
||||
|
||||
The resulting file, `receive`, unpacks the input files
|
||||
@@ -86,7 +86,7 @@ cmp ../README.md README.md
|
||||
### ABSTRACT
|
||||
|
||||
#### Minimal, Universal File Bundling (or, Functional Obfuscation in a Self-Decoding Unix Shell Archive)
|
||||
\
|
||||
|
||||
James A. Woods\
|
||||
Universities Space Research Association\
|
||||
NASA Ames Research Center
|
||||
@@ -94,7 +94,7 @@ NASA Ames Research Center
|
||||
---
|
||||
|
||||
> "Use an algorithm, go to jail."
|
||||
>\
|
||||
>
|
||||
> -- anon., circa 1988, pre-Morris worm era
|
||||
|
||||
----
|
||||
@@ -134,7 +134,7 @@ environment.
|
||||
> And he shows them pearly white
|
||||
> Just a jackknife has Macheath, dear--
|
||||
> And he keeps it out of sight.
|
||||
>\
|
||||
>
|
||||
> -- Bertolt Brecht, Threepenny Opera
|
||||
|
||||
----------------------------------------------
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#define C char
|
||||
#define F X,perror("oops"),1
|
||||
#define F X,fprintf(stderr,"oops\n"),1
|
||||
#define G getchar()
|
||||
#define I ;if(
|
||||
#define P putchar
|
||||
|
||||
+4
-4
@@ -11,16 +11,16 @@ for i in "${@?${usage?$0 file...}}";do<"$i"||exit;done
|
||||
#
|
||||
PATH=$PATH:. a=atob m=unshark z=zcat
|
||||
r="rm -f $a $m* $z" v="cc -Wno-implicit-function-declaration -o $z $m.c"
|
||||
trap "$r;exit 1" 1 2 13 15
|
||||
trap '$r;exit 1' 1 2 13 15
|
||||
echo decoding...
|
||||
(:|compress|./btoa|$a|$z)2>$m>&2||(sed '1,9s/./#define & /
|
||||
(:|compress|./btoa|./$a|./$z)2>$m>&2||(sed '1,9s/./#define & /
|
||||
s/@/[w]/g
|
||||
s/C/char /g
|
||||
s/I/;if(/g
|
||||
s/W/;while(/g
|
||||
s/Y/%lx /g
|
||||
s/}/;}/g'>$m.c<<_&&
|
||||
FX,perror("$m bite: resend"),1;
|
||||
FX,fprintf(stderr,"$m bite: resend\n"),1;
|
||||
GgetC()
|
||||
H(w=g())
|
||||
K[69001]
|
||||
@@ -43,5 +43,5 @@ Z,h@=w;n=8;f=Q+e;i=o=HIo<0)X,1;P(i)WH+1){Iw==Q&e){Z;m=n=8;f=QIH<0)X}
|
||||
c=wIw>=f)U++=i,w=oWw>=Q)U++=h@,w=t@;P(i=h@)Wp>D+Q)P(*--p)
|
||||
I(w=f)<1l<<k)t@=o,h[f++]=i;o=c}X}
|
||||
_
|
||||
($v)&&ln $z $a)&&$a<<\w>$m-&&$z<$m->$m&&tar xvf $m&&$r
|
||||
($v)&&ln -f $z $a)&&./$a<<\w>./$m-&&./$z<./$m->./$m&&tar xvf ./$m&&$r
|
||||
Z
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "Running shark.sh:"
|
||||
sh shark.sh README.md jaw.c README.md > receive || exit 1
|
||||
echo "Done."
|
||||
|
||||
echo "Attempting to extract files:"
|
||||
|
||||
mkdir -p test
|
||||
cd test
|
||||
sh ../receive
|
||||
@@ -579,46 +579,11 @@ You are welcome to try and fix it if you can!
|
||||
### Source code: [1990/jaw/jaw.c](1990/jaw/jaw.c)
|
||||
### Information: [1990/jaw/README.md](1990/jaw/README.md)
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed the scripts to
|
||||
work in modern systems. He notes however that the command in the try section,
|
||||
the one to test the official C entry, **appears** (the keyword!) to not work
|
||||
with macOS, giving:
|
||||
|
||||
|
||||
```sh
|
||||
$ echo "Quartz glyph jocks vend, fix, BMW." | compress | ./btoa | ./jaw
|
||||
oops: Undefined error: 0
|
||||
oops: Undefined error: 0
|
||||
```
|
||||
|
||||
However this is because the entry uses `perror()` and it just so happens that
|
||||
the default `errno` of 0 gives that result. For instance if you run the
|
||||
following C program under macOS you will get undefined error but if you do it
|
||||
under Linux you'll likely get success.
|
||||
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
int main()
|
||||
{
|
||||
errno = 0;
|
||||
printf("%d, %s\n", errno, strerror(errno));
|
||||
}
|
||||
```
|
||||
|
||||
In fact the condition which is in the `a()` function on line 18 of the entry
|
||||
namely:
|
||||
|
||||
I k>16)
|
||||
|
||||
is true on both linux and macOS, with `k` being equal to 22!
|
||||
|
||||
Should the entry use `perror()`? Perhaps not but we're not sure of its purpose
|
||||
so it should stay with this note.
|
||||
|
||||
If you want to try and fix this (mis)feature, you are welcome to try.
|
||||
It seems like the scripts do not work correctly, where not all files are
|
||||
extracted. Some work was done to get them to work some but it does not appear
|
||||
that all files can be extracted. For instance in the [try.sh](1990/jaw/try.sh)
|
||||
script which Cody added it is supposed to add the README.md file to the archive
|
||||
and it did at one point (or so he recalls) but now it doesn't seem to happen.
|
||||
|
||||
|
||||
## 1990 theorem
|
||||
|
||||
+9
-3
@@ -933,9 +933,15 @@ With these improvements the entry looks much more like the original!
|
||||
## [1990/jaw](1990/jaw/jaw.c) ([README.md](1990/jaw/README.md]))
|
||||
|
||||
Cody fixed the script to work properly in modern environments (to do with `$PATH`
|
||||
not having `.` in it). He notes that with an invocation in the try section will
|
||||
with macOS show what appears to be an error message but is actually okay. He
|
||||
gives more information in the [bugs.md](/bugs.md) file.
|
||||
not having `.` in it). Other adjustments were made as well.
|
||||
|
||||
He also changed the `perror(3)` call to `fprintf(3)` because in macOS when errno
|
||||
is 0 it shows what looks like an error.
|
||||
|
||||
He added the [try.sh](1990/jaw/try.sh) to run the commands that we suggested at
|
||||
the time. However, there is a known bug still, see [bugs.md](bugs.md) for
|
||||
details.
|
||||
|
||||
|
||||
NOTE: as `btoa` is not common we used a ruby script from Yusuke.
|
||||
|
||||
|
||||
Reference in new issue
Block a user