On Wed, Jun 14, 2017 at 12:04:35PM -0400, tetsu...@scope-eye.net wrote:
> So first off, the circular reference problem with "declare -n"
> apparently doesn't exist in Korn Shell: If you "typeset -n x=$1", and
> $1 is "x", it's not a circular reference.

Korn shell actually has two different *kinds* of functions.

If you declare using:  foo() { ...; }

Then you get bash-like behavior.

If you declare using:  function foo { ...; }

Then it works as you described.

$ ksh
$ foo() { typeset -n x="$1"; x=y; }
$ x=global
$ foo x
ksh: typeset: x: invalid self reference
$ function bar { typeset -n x="$1"; x=y; }
$ bar x
$ echo "$x"
y

As far as I know, bash has no equivalent of ksh's "function foo"
declaration.  Bash permits that *syntax* to be used as a function
declaration, but it has exactly the same semantics as "foo()".

> Regarding return values, there's a couple ways of looking at this:
> [...]

You're retracing a lot of the ground I've already covered in the last
few years.  Which is cool, and I'll be happy if you find something
that I missed.

Reply via email to