fix tty annoyance of 1989/jar.1

Instead of writing the literal output of the binary to /dev/tty,
we simulate the output by silencing stderr and by piping the binary
thru strings.

The raw binary executable output to /dev/tty was capable "ill effects".
Such "ill effects" could be as mild as printing strange characters, to
beeping (sometimes for extended periods), and even the termination
of the terminal app window in some cases.

The "ill effects" from the printing of the raw binary executable
is highly dependent on the compiler, compiler version, libc, crt0.o,
operating system, terminal app and/or terminal driver.  As such,
the "ill effects" that one user might see may be hard to reproduce
in order environments.  While some of the more extreme "ill effects"
might be unlikely, what was more common was for the binary output
to be interpreted strangely by the terminal app and/or driver to
the extent that the was lost or not well seen by the user.

This change introduces the ${STRINGS} Makefile variable to the
`/var/mk` file and uses to to "clean out" any output that might
produce such "ill effects".  Prior to the command, the echo does
clearly state:

```
NOTE: We will now simulate: cc -c -o /dev/tty jar.1.c
```

We also modify the `1989/jar.1/jar.1.sh` and `1989/jar.1/jar.1.alt.sh'
shell scripts to pipe raw binary through strings as well.

Thus the user can, if they wish, try the raw command themselves.
If that command does produce the more extreme examples of "ill
effects", the fault rests with the user.  We mention that the
Makefile will echo the command to stdout in the `README.md`.  But
that is as far as we go.  We do **NOT RECOMMEND** having a shell
script or Makefile rule that would write the raw binary to `/dev/tty`
but rather let the immigration of the user try or not try it.

In general, the use piping raw binary thru stings makes the original
output more apparent, as was the case when using dumb CRT terminals
that couldn't even process ANSI escape sequences were more common.
This commit is contained in:
Landon Curt Noll committed 2023-07-09 13:55:14 -07:00
1 parent 367d4af7b8
commit 606020a0c1
5 files changed
+70 -20

No files matched your search

+3 -2
View File
@@ -131,14 +131,15 @@ ${PROG}: ${PROG}.c
${RM} -f $@
${CP} jar.1.sh $@
${CHMOD} +x $@
${CC} -c -o /dev/tty jar.1.c
@echo NOTE: We will now simulate: ${CC} -c -o /dev/tty jar.1.c
${CC} -c -o /dev/stdout jar.1.c 2>/dev/null | ${STRINGS}
# alternative executable
#
alt: data ${ALT_TARGET}
@${TRUE}
${PROG}.alt: ${PROG.alt}.c
${PROG}.alt: ${PROG}.alt.c
@echo "NOTE: The original source might not compile using modern compilers."
${RM} -f $@
${CP} jar.1.alt.sh $@
+64 -16
View File
@@ -1,38 +1,86 @@
# Strangest abuse of the rules
Jari Arkko
Laboratory of Information Processing Science
Helsinki University of Technology
Otakaari 1
02150 Espoo
Finland
Jari Arkko
Laboratory of Information Processing Science
Helsinki University of Technology
Otakaari 1
02150 Espoo
Finland
## To build and run:
## To build:
```sh
make clobber all
```
## To run:
```sh
make clobber all
```
### Alternate code:
One may try:
```
./jar.1.sh
```
Or for the original $xurce might not compile using modern compilers, try:
```sh
make clobber alt
```
or even:
```sh
jar.1.alt.sh
```
## Judges' remarks:
On many systems the compiler will not allow you to send the object file to
/dev/tty. The author suggested:
`/dev/tty`. The author suggested:
```sh
cc -c -o /dev/tty jar.1.c
```
On systems that have symbolic links, we suggest:
As a last resort the `jar.1.sh` script provided simulates
writing the raw binary the .o file to the terminal.
```sh
ln -s /dev/tty jar.1.o
cc -c jar.1.c
```
Abuse of the rules winners usually result in a change of the rules.
Starting in 1990, compiling entries must result an regular file
which can be executed.
As a last resort the scripts provided simply cat the .o file to the terminal.
Under certain conditions that are dependent on such diverse things such as:
Abuse of the rules winners usually result in a change of the rules. Starting in
1990, compiling entries must result an regular file which can be executed.
- compiler type
- compiler version
- libc
- crt0.o
- operating system
- terminal application
- terminal driver
- various bugs and misfeatures :-)
the output of ray binary to a terminal can produce various effects
from the mildly annoying beeps to missing seeing the important
output, to various "ill effects" such as the crashing of the terminal
application. Instead we have opted to pipe raw binary thru the
strings utility before writing to standard output instead of
`/dev/tty`.
As a historical note, the Makefile does echo the original command
to standard output, the original shell command that did write raw
binary to the `/dev/tty` special file.
The use piping raw binary thru stings makes the original 1989 output
more apparent, as was the case when using dumb CRT terminals (some
do dumb that they couldn't even process simple ANSI escape sequences)
were more common.
## Author's remarks:
+1 -1
View File
@@ -4,5 +4,5 @@
# run/compile it
rm -f jar.1.alt.o
cc jar.1.alt.c -c
cat jar.1.alt.o
cat jar.1.alt.o | strings
rm -f jar.1.alt.o
+1 -1
View File
@@ -4,5 +4,5 @@
# run/compile it
rm -f jar.1.o
cc jar.1.c -c
cat jar.1.o
cat jar.1.o | strings
rm -f jar.1.o
+1
View File
@@ -187,6 +187,7 @@ SLEEP= sleep
SORT= sort
SSH= ssh
STAT= stat
STRINGS= strings
STRIP= strip
STTY= stty
SUM= sum