CLI platform independence for unix
CLI platform independence for Unix

This is a set of profile files that I use across a number of different Unix platforms to provide a consistent programming and systems maintenance interface at the CLI (command line interface) level on all.

Note that this "system" assumes the use of standard Unix shells such as sh, ksh, or bash. It makes no attempt to accomodate weirdo "divergent" shells such as csh or tcsh. (Wherever possible, I use bash (gnu). This may mean having to compile up from gnu source, but I've done this on all platforms with little effort, so you can too :-)

The differences at the CLI level between different Unix flavours are in many respects minor, but they're nevertheless irritating in the extreme. This makes it hard to remain productive as you move from one to the other on a day-to-day basis.

These differences at the CLI level manifest themselves via (mainly):

  • Programs and data which live in different directories on each system,

  • and
  • Programs which have the same name but which need different arguments to achieve the same (or similar) result.
  • The solution to such inconsistency across platforms is simply to determine the platform and OS as a shell is invoked and then set up the various paths, aliases, and functions to suit each one. And the challenge is to do this in a way which results in a consistent interface for the user.

    And it ain't that hard, really. Without going into any detail, I'll simply provide you here with the files I use to achieve this. These come as a set, and they are:

  • /etc/profile (general - executed by all users)
  • /usr/local/etc/profile (aliases - executed by all users)
  • /usr/local/etc/func (functions - executed by all users)
  • $HOME/.profile
  • $HOME/.bashrc
  • $HOME/.bash_profile (just a soft link to $HOME/.profile)
  • The third file above - /usr/local/etc/func - generates a number of shell functions to support sh (the Bourne Shell), which has no provision for aliases.

    The easiest way to see what this collection provides is to type "env" after you log in. Assuming ksh or bash, you can also type "alias" to print all defined aliases. And typing "typeset -f" will dump all defined functions.

    Note that (in /etc/profile) there is a "case" block towards the bottom which you will need to modify (or delete) for your own purposes. This is the bit that tries to define LINE for matching up with the users "terminal" (or window). It's mainly for remote logins, and I'll leave that as an exercise for the reader ...!


      Back to (Bluehaze) software archive page

     Bluehaze home page

    Administrator - Bluehaze Solutions. Last change: June 30, 2001