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
hash
Bourne shells with the hash
built-in have a subtle internal limit.
It becomes apparent, if the environment variable PATH
contains more than 255 elements.
Commands are not found by path search anymore, if they are at the right of the 255th element.
You might get an error message like "unknown builtin
" or "command not found
",
or an arbitrary built-in may even be called, like export
(then printing the environment variables).
That's the only resource-like limit of the Bourne shell I am aware of,
and it's of rather theoretical nature.
I believe Steve Bourne took care to avoid any such limits.
The symptoms are related to the hash
built-in:
hash -r
" was called in advance, it does trigger
hash
, have no limit here
Here is an example,
PATH=/bin export PATH i=1; while [ "$i" -lt 255 ]; do PATH=/:$PATH i=`/usr/bin/expr $i + 1` done echo hashing ok: echo $PATH|tr : ' '|wc -w # how many elements? hash -r; printf 'found printf\n' # search printf(1) PATH=/:$PATH # add one element to exceed limit echo hashing fails: echo $PATH|tr : ' '|wc -w hash -r; printf 'found printf\n' # and search printf(1) againwhich produces this output:
hashing ok: 255 found printf hashing fails: 256 unknown builtin
I don't know the very nature, yet, but I believe the error
message results from a corrupted data structure
(concerning PATH search) somewhere near hash.c: hfind()