From 874161011026d3791da5837f318df278cf79ee87 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 1 Nov 2023 04:47:01 -0700 Subject: [PATCH] Fix script in 1990/jaw Now the files added to the archive will be extracted. It is unfortunate but a temporary tarball has to be formed rather than writing to stdout. There is a possible fix to this but it hasn't been looked into yet. The tarball is temporary, however, and is deleted after it is extracted. The script MUST be run from a subdirectory of the entry but as the script had hardcoded the paths before this shouldn't be that big of a deal. Another problem was more to do with paths and also the script relying on the exit code allowing for &&. Now it's ';' between most commands. There still remains, Landon and I believe, a bug in the entry and this has been added to the bugs.md file; the script not working has been removed from the bugs.md. --- 1990/jaw/README.md | 13 ------------- 1990/jaw/shark.sh | 8 ++++---- 1990/jaw/try.sh | 2 +- thanks-for-fixes.md | 11 +++++++---- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/1990/jaw/README.md b/1990/jaw/README.md index 89f0192df..f60eb1b5b 100644 --- a/1990/jaw/README.md +++ b/1990/jaw/README.md @@ -1,22 +1,12 @@ # Best Entropy-reducer James A. Woods\ -Research Institute for Advanced Computer Science\ -MS 230-5\ -NASA Ames Research Center\ -Moffett Field, CA 94131\ US Karl F. Fox\ -Morning Star Technologies, Inc.\ -1760 Zollinger Road\ -Columbus, OH 43221\ US Paul Eggert\ -Twin Sun Inc.\ -360 N. Sepulveda Blvd. #2055\ -El Segundo, CA 90245\ US ## To build: @@ -25,9 +15,6 @@ US make all ``` -NOTE: see the [bugs.md](/bugs.md) file for information on what appears to be a -bug in macOS but is actually not. - ### Bugs and (Mis)features diff --git a/1990/jaw/shark.sh b/1990/jaw/shark.sh index bd0e8b675..622b7e072 100755 --- a/1990/jaw/shark.sh +++ b/1990/jaw/shark.sh @@ -1,5 +1,5 @@ for i in "${@?${usage?$0 file...}}";do<"$i"||exit;done -(cat&&tar cbf 1 - "$@"|compress|./btoa&&echo w)<<\Z +(cat&&tar cbf 1 unshark.tar "$@"|compress|./btoa&&echo w)<<\Z #!/bin/sh # # GENTLE READER -- write this message to file [no headers!]; run "sh file". @@ -9,11 +9,11 @@ for i in "${@?${usage?$0 file...}}";do<"$i"||exit;done # # "Cleverly he dialed from within." -- D. Van Vliet, "Trout Mask Replica" # -PATH=$PATH:. a=atob m=unshark z=zcat +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 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 @@ -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<./$m-&&./$z<./$m->./$m&&tar xvf ./$m&&$r +($v);ln -f $z $a);./$a<<\w>./$m-&&./$z<./$m->./$m;tar xvf ../$m.tar&&$r Z diff --git a/1990/jaw/try.sh b/1990/jaw/try.sh index a4c337b57..eed759a3b 100755 --- a/1990/jaw/try.sh +++ b/1990/jaw/try.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash echo "Running shark.sh:" -sh shark.sh README.md jaw.c README.md > receive || exit 1 +sh shark.sh shark.sh README.md jaw.c > receive || exit 1 echo "Done." echo "Attempting to extract files:" diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index de4dc0211..ef4c4e0c4 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -932,16 +932,19 @@ 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). Other adjustments were made as well. +Cody fixed the script to work properly in modern environments including paths, +writing to and extracting from stdout, (to do with `$PATH` +not having `.` in it) and relying on the exit code in the commands to allow for +`&& ...`. 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. +the time. +However, there is a known bug still, see [1990 jaw in +bugs.md](/bugs.md#1990-jaw) for details. NOTE: as `btoa` is not common we used a ruby script from Yusuke.