Annotation of coherent/b/bin/sh.420/tripsh, revision 1.1

1.1     ! root        1: # Some simple things that the shell has failed on in the past.
        !             2: 
        !             3: # The remainder of a line after a partial comment has to be scanned
        !             4: 
        !             5: : ${OK=3}
        !             6: if [ ! $OK ]; then
        !             7:        echo "Failed to look at input after \":\"" 1>&2
        !             8: fi
        !             9: 
        !            10: # Some shells don't deal very well with keywords
        !            11: 
        !            12: echo if >/dev/null
        !            13: 
        !            14: # Can we declare functions?
        !            15: 
        !            16: somefunc () {
        !            17:        A=$#
        !            18:        set "$@"
        !            19:        if [ $A -ne $# ]; then
        !            20:                echo "Problems expanding null parameters with \$@"
        !            21:        fi
        !            22: }
        !            23: 
        !            24: # Is "$@" parameter expansion working properly?
        !            25: 
        !            26: somefunc a b "" c ""
        !            27: 
        !            28: somefunc () {
        !            29:        A=$#
        !            30:        set X "$@"
        !            31:        if [ `expr $# - 1` -gt $A ]; then
        !            32:                echo "\"\$@\" with no positional parameters should expand" \
        !            33:                        "to nothing whatsoever"
        !            34:        fi
        !            35: }
        !            36: 
        !            37: somefunc
        !            38: 
        !            39: # Can we run functions in subshells ?
        !            40: 
        !            41: (somefunc X)
        !            42: 
        !            43: # A backquote (aka grave) expression of a command that outputs nothing should
        !            44: # expand to nothing whatsoever.
        !            45: 
        !            46: set X `echo`
        !            47: if [ $# -gt 1 ]; then
        !            48:        echo "\`echo\` should expand to nothing whatsoever"
        !            49: fi
        !            50: 
        !            51: # Is the management of here-documents in functions up to scratch?
        !            52: 
        !            53: somefunc () {
        !            54:        echo <<'end' >/dev/null
        !            55:        This is a test
        !            56: end
        !            57:        echo <<'end' >/dev/null
        !            58:        This is a test
        !            59: end
        !            60:        echo <<'end' >/dev/null
        !            61:        This is a test
        !            62: end
        !            63:        echo <<'end' >/dev/null
        !            64:        This is a test
        !            65: end
        !            66:        echo <<'end' >/dev/null
        !            67:        This is a test
        !            68: end
        !            69:        echo <<'end' >/dev/null
        !            70:        This is a test
        !            71: end
        !            72:        echo <<'end' >/dev/null
        !            73:        This is a test
        !            74: end
        !            75:        echo <<'end' >/dev/null
        !            76:        This is a test
        !            77: end
        !            78: }
        !            79: 
        !            80: somefunc
        !            81: 
        !            82: # Can we have nested backquote-expressions?
        !            83: 
        !            84: if [ foo != `echo \`echo foo\`` ]; then
        !            85:        echo Nested backquote-expressions not supported
        !            86: fi
        !            87: 
        !            88: # Can we have nested ${} - style variable-expansions?
        !            89: 
        !            90: if [ foo != ${C=${D=foo}} -o $C != foo -o $D != foo ]; then
        !            91:        echo Problem with nested \${}-subsitutions
        !            92: fi
        !            93: 
        !            94: # Can we unset variables?
        !            95: 
        !            96: unset C D
        !            97: 
        !            98: if [ -n "$C" -o -n "$D" ]; then
        !            99:        echo Problem with unsetting variables
        !           100: fi
        !           101: 
        !           102: # Is full word expansion working with ${}?
        !           103: 
        !           104: C=${C:=`echo testing...`}
        !           105: 
        !           106: if [ "$C" != testing ]; then
        !           107:        echo Problem with graves inside \${}
        !           108: fi
        !           109: 
        !           110: # Things known not to work in Coherent sh:
        !           111: #      unset

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.