On mar., 2017-03-14 at 11:43 +0000, Thorsten Glaser wrote: > Jean Delvare dixit: > >> if [[ $KSH_VERSION = *@(MIRBSD|LEGACY)\ KSH* ]]; then > >> function unset { > >> local __foo > >> > >> for __foo in "$@"; do > >> eval "unset $__foo[*]" > >> done > >> } > >> fi > > > >Does that actually work? It doesn't seem like special shell builtins > >can be overloaded with functions, and unset is a special shell builtin. > > Ouch. I admit not having tested it. But you can name the function x_unset > and then define an alias. Aliases are parse-time and thus will be used > in favour of builtins of any kind.
Tried it. My first attempt resulted in a delay followed by: Segmentation fault (core dumped) so I was hesitant to recommend it to my customer ;-) Then I realized the code was infinitely recursive, as the unset in eval is caught by the alias. Escaping it with \\ solved the problem, and then yes, it works. Thanks for the suggestion, which I have forwarded to my customer. > (...) > True, but this is Unix, we give users the rope to hang themselves. Sure. And the stool. And a fine manual explaining how to make a noose right. > (...) > Thanks, applied… I didn’t catch this because BSD mdoc, in contrast > to GNU’s, did this right already with the No. The language used for man pages seems to be the least portable thing on earth, right after shells and shell scripts ;-) -- Jean Delvare SUSE L3 Support