On 01/04/2025 12:49, Igor Todorovski wrote:
Hi,
I currently maintain a set of enablement patches for coreutils for z/OS. They
are available here (a few of them need cleanup):
https://github.com/zopencommunity/coreutilsport/tree/main/stable-patches/src
z/OS is unique in that files can contain a file tag attribute, which consists
of a ccsid encoding and text flag. Programs can also run in either EBCDIC or
ASCII mode, and the z/OS C runtime automatically converts data tagged with a
codepage to the program encoding on read, and vice versa on write.
In some cases we need to disable this “auto conversion” where the data needs to
be read verbatim as in
https://github.com/zopencommunity/coreutilsport/blob/main/stable-patches/src/basenc.c.patch.
We also extended stat to include additional attributes here:
https://github.com/zopencommunity/coreutilsport/blob/main/stable-patches/src/stat.c.patch
Thanks for the info.
Another question I have is with respect to ls. z/OS ships an old version of ls
with z/OS extensions. One of those extensions is ls -T, which prints out the
file tag. However, this conflicts with coreutils ls -T:
-T When printing in the long (-l) format, display complete time
information for the
file, including month, day, hour, minute, second, and year. The
-D option gives
even more control over the output format. This option is not
defined in IEEE Std
1003.1-2008 (“POSIX.1”).
In fact the above is from FreeBSD / macOS.
coreutils is different again:
-T, --tabsize=COLS
assume tab stops at each COLS instead of 8
Here’s the z/OS ls:
https://www.ibm.com/docs/en/zos/2.4.0?topic=descriptions-ls-list-file-directory-names-attributes
-T
Displays file tag information associated with the file. The format of this
output will be similar to the output from chtag -p.
An example output:
ls -T file
t IBM-1047 T=on file1
ls -T does not turn on the -l option. ls -T can be used with other options. See Long
output
format<https://www.ibm.com/docs/en/zos/2.4.0?topic=descriptions-ls-list-file-directory-names-attributes#lscmd__longf>
for details.
We haven’t implemented this in coreutils as of yet, but we would like to for
compatibility. What approach would you suggest? Can we propose a compatibility
environment variable or detect if the host system is z/OS?
Well I suppose you could patch your coreutils to keep -T for z/OS functionality
and --tabsize for coreutils functionality.
Scripts are already incompat wrt -T short option, so you wouldn't really have
to worry about that.
cheers,
Padraig