posix shell testing on various Unix-like systems circa 2003

a script tested on:

 Mac OS 10.2.4, Linux, HP-UX 11i, and Korn in windo$.

john meister
------------------------------------
++++++++++++++++++++++++++++++++++++
original script:
#!/bin/sh
echo "This is a test script to ascertain the Posix compliance of your shell"
echo ""
# test one: backtick alternatives
echo -n "1. The current date is:"
echo $(date)
# test two: expr versus $(( ))
echo "2. The sum of 2+2 is: $((2 + 2))"
# test three: variable slicing
echo -n "3. The first character of the word 'xyzzy' is:"
testvar="xyzzy"
y=${testvar#?}              # Lop off first char, assign to 7
z=${testvar%$y}             # Lop off chars in y from end of x
echo "$z"
# test four, locale issues
echo -n "4. The following should be the word 'BLETCHLEY' in lowercase:"
echo BLETCHLEY | tr '[:upper:]' '[:lower:]'
echo "5. The next line of output should be 'enigma', but not 'CODEBREAKER'"
grep '[[:lower:]]' << EOF
        enigma
        CODEBREAKER
EOF
# sed portability
echo "6. Checking to see if your sed implementation supports the -e flag:"
echo "       failure" | sed -e 's/fail/suc/' -e 's/ure/cess/'
# multiple variable assignments on one line with no semicolon?
a=1  b=2  c=3
echo "7. Multiple variable set test: a,b,c should count 1-3: $a, $b, $c"
# does your sort support -u ?
echo "8. Is sort -u supported? You should only see one occurance of 'yes' 
below"
sort -u << EOF
        yes
        yes
        yes
EOF
echo "-------------------------"
uname -a
echo "-------------------------"
echo "All done. Thanks!"
exit 0

++++++++++++++++++++++++++++++++++++


Script results:

korn shell on Windows XP:
===============================
Welcome to the Interix UNIX utilities.

DISPLAY=JM2:0.0
$ cd /dev/fs/D
$ vi test.sh
$ ./test.sh
This is a test script to ascertain the Posix compliance of your shell

-n 1. The current date is:
Tue Mar 11 19:48:27 PST 2003
2. The sum of 2+2 is: 4
-n 3. The first character of the word 'xyzzy' is:
x
-n 4. The following should be the word 'BLETCHLEY' in lowercase:
bletchley
5. The next line of output should be 'enigma', but not 'CODEBREAKER'
        enigma
6. Checking to see if your sed implementation supports the -e flag:
        success
7. Multiple variable set test: a,b,c should count 1-3: 1, 2, 3
8. Is sort -u supported? You should only see one occurance of 'yes' below
        yes
-------------------------
Interix JM2 3.0 SP-7.0.1701.1 x86
-------------------------
All done. Thanks!
$
===================================
FROM MY HP C3000 running HP-UX 11i, Dec 2002 release


root@hpc3000 [/root]

 >--> ./test.sh
sh: ./test.sh: Execute permission denied.

  -----------------------------------------------------
root@hpc3000 [/root]

 >--> sh ./test.sh
This is a test script to ascertain the Posix compliance of your shell

-n 1. The current date is:
Tue Mar 11 19:52:52 PST 2003
2. The sum of 2+2 is: 4
-n 3. The first character of the word 'xyzzy' is:
x
-n 4. The following should be the word 'BLETCHLEY' in lowercase:
bletchley
5. The next line of output should be 'enigma', but not 'CODEBREAKER'
        enigma
6. Checking to see if your sed implementation supports the -e flag:
        success
7. Multiple variable set test: a,b,c should count 1-3: 1, 2, 3
8. Is sort -u supported? You should only see one occurance of 'yes' below
        yes
-------------------------
HP-UX hpc3000 B.11.11 U 9000/785 2002751315 unlimited-user license
-------------------------
All done. Thanks!

  -----------------------------------------------------
root@hpc3000 [/root]

==========================================================

On my Linux system:
------------------------------------------------
john@cafe [/wagoneers/home/john]
------------------------------------------------
--> sh ./test.sh
This is a test script to ascertain the Posix compliance of your shell

1. The current date is:Tue Mar 11 19:54:36 PST 2003
2. The sum of 2+2 is: 4
3. The first character of the word 'xyzzy' is:x
4. The following should be the word 'BLETCHLEY' in lowercase:bletchley
5. The next line of output should be 'enigma', but not 'CODEBREAKER'
        enigma
6. Checking to see if your sed implementation supports the -e flag:
        success
7. Multiple variable set test: a,b,c should count 1-3: 1, 2, 3
8. Is sort -u supported? You should only see one occurance of 'yes' below
        yes
-------------------------
Linux cafe 2.0.37 #2 Thu May 13 12:28:17 PDT 1999 i686 unknown
-------------------------
All done. Thanks!

------------------------------------------------
john@cafe [/wagoneers/home/john]
------------------------------------------------

==========================================================
ON MAC OS 10.2.4:


-> more mac.results
  [john-n-:~] john% sh ./test.sh
This is a test script to ascertain the Posix compliance of your shell

1. The current date is:Tue Mar 11 19:59:18 PST 2003
2. The sum of 2+2 is: 4
3. The first character of the word 'xyzzy' is:x
4. The following should be the word 'BLETCHLEY' in lowercase:bletchley
5. The next line of output should be 'enigma', but not 'CODEBREAKER'
        enigma

[john-n-:~] john%

=====================================================================
        John Meister
       Adjunct Faculty - Computer Science Dept.
=====================================================================


ebook:
Full Size
Jeep Buyer's
Guide
ebook:
Practical Suggestions
for Microsoft
Windows
Linux Tackles Microsoft
12 hour Video Course by john:
The Art of Linux System Administration
published by O'Reilly Media
Study Guide for the LPIC-2 Certification Exams
search for:
on the internet, or:
JohnMeister.com-fotos
LinuxMeister-Linux
BibleTech-
Bible overview


An overview of Biblical history:
"Promises and Prophets"

Wagoneers

FULL SIZE JEEPS

JeepMeister
"Jeep is America's
only real sports car."
-Enzo Ferrari


MeisterTech
Diesels +

One Page Overview of Linux Commands

click for an image of the 5 essential Linux commands

An Intro to Linux
AMSOIL product guide,
or, AMSOIL web, or 1-800-956-5695,
use customer #283461

Amsoil dealer since 1983
purchase AMSOIL
at Midway Auto on SR9 in Snohomish,
or at Northland Diesel in Bellingham, WA


SJ - 1962-1991

XJ - 1984-2001

WJ - 1999-2004

KJ - 2002-2007

WK - 2005-2010

Find the recommended
AMSOIL synthetics
for your Jeep

CJ-10A - 1984-1986

Jeepsters

MJ - 1984-1992

Willys - 1946-1965

Other Jeeps (FC)