Add 1998/bas2/try.sh + format/typo check README.md

The try.sh allows one to pass in args: if a readable regular file it
will be fed to the program and otherwise it'll act as if it's a string.
It also has some additional commands that I thought might be fun to show
the entry.

Format/typo check README.md file.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-13 08:33:08 -08:00
1 parent aa1427f18e
commit d742eb23e7
3 files changed
+60 -3

No files matched your search

+15 -3
View File
@@ -8,12 +8,23 @@ make all
## To use: ## To use:
```sh ```sh
./bas2 < bas2.c ./bas2 < file
echo text | ./bas2
```
## Try:
```sh
./try.sh
./try.sh "foo bar" "baz" "IOCCC 1998/bas2" README.md
``` ```
## Judges' remarks: ## Judges' remarks:
### Questions to ponder: ### Questions to ponder:
Can you determine the relationship between the input and the resulting numeric Can you determine the relationship between the input and the resulting numeric
@@ -22,6 +33,7 @@ output?
The program was not designed to process files with a certain octet value, what The program was not designed to process files with a certain octet value, what
value is that? value is that?
### Hint and Extra Credit: ### Hint and Extra Credit:
This entry points out a minor flaw in the IOCCC rules that has This entry points out a minor flaw in the IOCCC rules that has
@@ -40,10 +52,10 @@ done by matching the bit patterns. Minor obfuscations are:
- Useless variable names. - Useless variable names.
- Recursive main() instead of 2 loops (over input characters and over bits in - Recursive `main()` instead of 2 loops (over input characters and over bits in
the character). the character).
- `?` and `||` instead of if statements. - `?:` and `||` instead of if statements.
## Copyright and CC BY-SA 4.0 License: ## Copyright and CC BY-SA 4.0 License:
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate 1998/bas2
#
# If any args are specified it checks if it's a readable file and if it is it
# feeds it to the program. If not it assumes it's a string and feeds that to the
# program.
#
make all || exit 1
echo "$ ./bas2 < bas2.c" 1>&2
./bas2 < bas2.c
echo "$ ./bas2 < README.md" 1>&2
./bas2 < README.md
echo "$ ./bas2 < Makefile" 1>&2
./bas2 < Makefile
echo "$ echo foo bar baz | ./bas2" 1>&2
echo foo bar baz | ./bas2
echo "$ cat README.md Makefile bas2.c | ./bas2" 1>&2
cat README.md Makefile bas2.c | ./bas2
# while we have an arg check if it's a file. If it is a regular file that is
# readable feed it to the program; otherwise act as if it's a string.
while [[ "$#" -gt 0 ]]; do
if [[ -f "$1" && -r "$1" ]]; then
echo "$ ./bas2 < $1" 1>&2
./bas2 < "$1"
else
echo "$ echo $1 | ./bas2" 1>&2
echo "$1" | ./bas2
fi
shift 1
done
+7
View File
@@ -2042,6 +2042,12 @@ they do have page up and page down but this gives a default for those who don't
have them like with Macs. have them like with Macs.
## [1998/bas2](1998/bas2/bas2.c) ([README.md](1998/bas2/README.md]))
Cody added the [try.sh](1998/bas2/try.sh) script which runs some default actions
as well as allowing one to pass in different file names or strings.
## [1998/chaos](1998/chaos/chaos.c) ([README.md](1998/chaos/README.md])) ## [1998/chaos](1998/chaos/chaos.c) ([README.md](1998/chaos/README.md]))
Cody added a call to `endwin()` to restore terminal sanity (echo etc.) when Cody added a call to `endwin()` to restore terminal sanity (echo etc.) when
@@ -2059,6 +2065,7 @@ by changing the typedef `lint` (to `int` - see the code for why this has to be
done in modern systems) to be `_int`. done in modern systems) to be `_int`.
## [1998/dlowe](1998/dlowe/dlowe.c) ([README.md](1998/dlowe/README.md]))
## [1998/dlowe](1998/dlowe/dlowe.c) ([README.md](1998/dlowe/README.md])) ## [1998/dlowe](1998/dlowe/dlowe.c) ([README.md](1998/dlowe/README.md]))
Cody made the program more portable by changing the void return type of `main()` Cody made the program more portable by changing the void return type of `main()`