This problem arises with an autoloaded function intended to override a
program. In s+ (as currently shipped with MacOS) it works as I expect.
In the earliest 93t I can conveniently run, the function definition is
lost in favour of a tracked alias of the program:

  $ ksh run-me-from-here
  Version M 1993-12-28 s+
  example is a function
  PASS
  example is a function
  PASS
  $
  $ /opt/ast/arch/darwin9.ppc/bin/ksh run-me-from-here
  Version M 93t 2008-11-04
  example is an undefined function
  PASS
  example is a tracked alias for /Users/kevin/kshtest/bin/example
  FAIL
  $

The test case is appended.

This does not happen if the function is defined explicitly, rather than on
first use, and seems to happen only if FPATH is set for the program in the
function. My actual use case is:

  function vi
  {
    FPATH=$FPATH ${VISUAL:-vi} "$@"
  }

... where I want FPATH available to non-interactive subshells of vi, but
don't want to export it in general. A workaround is to run the program
using env, i.e.

  function vi
  {
    env FPATH=$FPATH ${VISUAL:-vi} "$@"
  }


# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".
#
echo c - kshtest
mkdir -p kshtest > /dev/null 2>&1
echo c - kshtest/bin
mkdir -p kshtest/bin > /dev/null 2>&1
echo c - kshtest/fun
mkdir -p kshtest/fun > /dev/null 2>&1
echo x - kshtest/run-me-from-here
sed 's/^X//' >kshtest/run-me-from-here << 'END-of-kshtest/run-me-from-here'
X#!/bin/ksh
X
XFPATH=$PWD/fun
XPATH=$PWD/bin
X
Xprint ${.sh.version}
Xtypeset -fu example
Xwhence -v example
Xexample
Xwhence -v example
Xexample
END-of-kshtest/run-me-from-here
chmod +x kshtest/run-me-from-here
echo x - kshtest/bin/example
sed 's/^X//' >kshtest/bin/example << 'END-of-kshtest/bin/example'
Xecho ${1:-FAIL}
END-of-kshtest/bin/example
chmod +x kshtest/bin/example
echo x - kshtest/fun/example
sed 's/^X//' >kshtest/fun/example << 'END-of-kshtest/fun/example'
X
Xfunction example
X{
X  FPATH=$FPATH bin/example PASS
X}
END-of-kshtest/fun/example
exit


-- 
Kevin Schoedel <[email protected]> VA3TCS

_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to