Bourne
| Ash
| #!
| find
|
ARG_MAX
| Shells
| whatshell
| portability
| permissions
| UUOC
| ancient
| -
| ../Various
| HOME
"$@"
| echo/printf
| set -e
| test
| tty defs
| tty chars
|
$() vs
)
| IFS
| using siginfo
| nanosleep
| line charset
| locale
Functions and positional parameters: SVR2 vs SVR3 ff.
The SVR2 variant of the Bourne shell introduced functions.
It was documented that:
Execution
[...] The positional parameters 1,ドル 2,ドル .... are set to the
arguments of the function.
So this behaviour
- is not a bug,
- and it's consistent, because functions modify
the global environment also in any other aspect:
- current working directory
- variables
- error flag ("set -e")
- further function definitions
However, this behaviour is not intuitive when having background
in other programming languages.
The behaviour was changed with the following SVR3 variant.
The decisions how to go on with SVR2 based shells were different now:
- HP-UX always kept the SVR2 based shell
and they never changed this behaviour.
Instead they added a note to the WARNING
section of the manpage.
- OFS1 always kept the SVR2 variant, too,
but they did change the behaviour.
Interestingly, they wrongly still document the old
behaviour until today.
- In Version 8, the SVR2 variant was taken as code base for numerous
further changes, mainly aiming towards a cleaner and more
consistent design - and probably for this reason the behaviour
of functions was not changed here.
There's also a thread with numerous different points of view on
the issue, see
<316526A3.2541@ats.nld.alcatel.nl> and ff., 04/96
starting in comp.unix.shell, comp.sys.hp.hpux, comp.sys.hp.apps,
comp.unix.internals.