Add alt code, scripts + format fixes in 2000/tomx

The alt code is based on the author's remarks with a fix so that it
actually works (I presume it once did work but it no longer did). This
compiles mkentry.c and running tomx.alt ends up running mkentry!

The try.sh script shows the different ways tomx.c can be used: as a
script, as a compiled file and as a Makefile. 'tomx.c' as a shell script
compiles itself and as a Makefile it does the same thing!

The try.alt.sh does more or less the same thing as try.sh but it works
for the alt code which works with mkentry.c (see above).

Format/typo fix README.md.

Although the try.sh and try.alt.sh script both chmod +x the source code
the code here in the repo is now +x as well because it can be used as a
script and a Makefile as well as compiled as C.

I believe this completes the review of 2000/tomx.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-13 14:36:24 -08:00
1 parent a979195d7b
commit 211a27769e
8 files changed
+125 -14

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
#
# try.sh - script to show 2000/tomx
if [[ ! -f "tomx" || ! -e "tomx" ]]; then
echo "Compiling tomx.c:" 1>&2
make all || exit 1
fi
echo "Running tomx:" 1>&2
echo "$ ./tomx" 1>&2
./tomx
echo 1>&2
echo "Using source code to compile tomx.c: " 1>&2
echo "$ rm -f tomx" 1>&2
rm -f tomx
echo "$ chmod +x tomx.c" 1>&2
chmod +x tomx.c
echo "$ ./tomx.c" 1>&2
./tomx.c
echo "Running tomx again:" 1>&2
echo "$ ./tomx" 1>&2
./tomx
echo 1>&2
echo "Using tomx.c as a Makefile:" 1>&2
echo "$ rm -f tomx" 1>&2
rm -f tomx
echo "$ make -f tomx.c" 1>&2
make -f tomx.c
echo "Running tomx again:" 1>&2
echo "$ ./tomx"
./tomx