Writing Portable Shell Scripts on z/OS UNIX


z/OS UNIX is a facet of z/OS that makes the operating system more approachable to those of us who weren’t brought up around 3270 terminals. Amongst other things, it provides support for remoting into the z/OS mainframe under a choice of UNIX shells (a simple Bourne-style shell or tcsh), access to a hierarchical file system, and a handful of Unix tools like ls, vi and grep (which work fine, as long as you don’t expect them to behave quite the same way as on other Unix systems). Like the rest of the operating system, z/OS UNIX is an EBCDIC environment.

EBCDIC Variants

My previous post brought up the topic of variant characters in EBCDIC. In summary, the characters shown below can be represented by different byte values depending on the locale under which a user is running:

^ ~ ! [ ] { } # | ` $ @

This raises following question: how can you distribute a z/OS UNIX shell script that will “just work” for any z/OS user, given that entities like the comment character (#), hashbang (#!), pipes (|) and the variable marker ($) might need to be represented by different bytes in different locales? Continue reading “Writing Portable Shell Scripts on z/OS UNIX”