summaryrefslogtreecommitdiffhomepage
path: root/DESIGN.md
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-27 17:59:21 -0600
committerSean Kurtz <seankurtz75@gmail.com>2026-11-27 17:59:21 -0600
commit8b4a1936d952dd43929c430e18d4e29f1f91d6b6 (patch)
tree7293c9242bbb9598d4e078aa9370776a7151f8f1 /DESIGN.md
parent1b00c3d4749038add86bb799d453f1bcd71b52af (diff)
downloadzash-fix/zos-tagging-and-csi.tar.gz
docs: the tagging rule as the code does it, and input errors in the specfix/zos-tagging-and-csi
DESIGN.md's "File tags" table said an ASCII build defers the tag on a `>` target and takes the first writer's CCSID; sys_zos.c tags a file the shell creates as IBM-1047 text and converts its own writes, and the paragraph "the tag follows the writer" now says that deferred tags are the _TAG_REDIR_* cases only. The shell's own stdout and stderr are in the table now, and the reason the inherited conversion is harmless to a binary writer (gzip turns it off, and tests/zos/tagging.sh checks the archive) is written down. The specification records what a script reviewer needs: R-LEX-17 no longer just ends the body at end of input, it says zash does not warn where bash does, and the new zash-only error rule gives 127/126 for a script that cannot be opened and 2 for a read error while input is being read. The PDF is regenerated.
Diffstat (limited to 'DESIGN.md')
-rw-r--r--DESIGN.md22
1 files changed, 17 insertions, 5 deletions
diff --git a/DESIGN.md b/DESIGN.md
index c641552..a276e09 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -520,7 +520,7 @@ adds what it needs to work beside EBCDIC programs.
| Situation | EBCDIC build | ASCII build |
| --- | --- | --- |
-| `>`, `>\|`, `>>` creating or truncating an untagged file, variable unset | nothing (as `/bin/sh`) | deferred text tag: CCSID of the first writer |
+| `>`, `>\|`, `>>` creating or truncating an untagged file, variable unset | nothing (as `/bin/sh`) | new or empty target: tagged IBM-1047 text, the shell's writes converted; target with data: tag left alone, writes still converted |
| `_TAG_REDIR_OUT` / `_ERR` = `TXT` or `BIN`, untagged empty target on fd 1 / 2 | deferred tag, text flag on / off | same |
| target already tagged, or has data, or is a device | left alone | left alone |
| `_TAG_REDIR_IN=TXT`, tagged input on fd 0 | `F_CONTROL_CVT` `SETCVTON` from the tag | same |
@@ -530,6 +530,7 @@ adds what it needs to work beside EBCDIC programs.
| here-document temp file | nothing | tagged IBM-1047 text |
| script, `.` file, profile, `ENV` tagged in the other CCSID | conversion on for the descriptor | same |
| untagged script | first 512 bytes sniffed (0x15 vs 0x0A newlines) | same |
+| standard output or error inherited untagged, not a terminal | nothing (as `/bin/sh`) | tagged IBM-1047 text, conversion on |
| process start | autoconvert left as the user set it | autoconvert switched on if off |
Decisions and reasons:
@@ -542,10 +543,21 @@ Decisions and reasons:
- Pipeline stages. A prefix on a stage tags that stage's pipe end:
`_TAG_REDIR_OUT=TXT a | b` tags `a`'s output, as documented for
`/bin/sh`.
-- The tag follows the writer. A deferred tag takes the CCSID of the
- first program that writes, so an EBCDIC tool behind `>` in an ASCII
- shell still produces a correctly tagged IBM-1047 file.
-- Pipes in ASCII builds are IBM-1047. If they were tagged 819 (as
+- The tag follows the writer, where the tag is deferred. A deferred tag
+ (the `_TAG_REDIR_*` cases) takes the CCSID of the first program that
+ writes, so an EBCDIC tool behind `>` in an ASCII shell still produces a
+ correctly tagged IBM-1047 file.
+- The shell's own redirections write IBM-1047. In an ASCII build the file
+ a `>` creates, and an inherited standard output that is a file, are
+ tagged IBM-1047 and the shell's own writes are converted, so `echo x >f`
+ leaves the EBCDIC text `/bin/sh` would have left, and an ASCII reader
+ gets it back through the tag. That conversion is on the descriptor, so it
+ is the one thing a child could inherit that it does not want: a program
+ that writes binary turns conversion off for its own descriptor (gzip
+ does), and `tests/zos/tagging.sh` checks that an archive made through
+ zash is byte for byte the archive made without it.
+- What is left of a file is only touched when it is untagged: a target
+ that already has a tag, or is a device, keeps its own.- Pipes in ASCII builds are IBM-1047. If they were tagged 819 (as
zoslib does) an EBCDIC reader would see ASCII. Tagged 1047, ASCII
writers are converted on write and ASCII readers on read. Between two
ASCII programs that costs two conversions per byte. `set +o pipetag`