Properly type check values for APPEND to file ports

Currently, APPEND on a file port! is just a shortcut for WRITE/append.
However, APPEND has a less restrictive type spec than WRITE/append.
WRITE only accepts [binary! string! block!], whereas APPEND accepts any
type.

Currently, calling APPEND on a file port with a value not also supported
by WRITE has a high chance of crashing the interpreter. For example,
consider CureCode issue 1894:

    >> p: open/new %pokus.txt
    >> append p #"x"  ;; Crashes the interpreter.

This commit fixes the crash by adding additional type checks for APPEND
on file ports:

    >> p: open/new %pokus.txt
    >> append p #"x"
    ** Script error: invalid argument: #"x"
    ** Where: append
    ** Near: append p #"x"

This fixes CureCode issue 1894.
Rename variables to improve clarity
Type-check call of TRY/except handler

TRY/except now checks that the typespec of a handler function actually
allows calls with the error value, before calling the handler function.

This fixes CureCode issue #1514.
[Linux] Fix Xshm detection

Error handler should be restored after XSync, or the new handler doesn't
take effect.

This fixes a crash when running graphics over ssh (if XSHM is built in).
Check type of argument before call comparator in sort

This fixes CC#1516

>> sort/compare [1 2 #[unset!]] :>
; The R3 process crashes at this point without a system exception