Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

User defined functions were implemented similarly as external execs in early shells. As the script was parsed, functions were dropped into /tmp without their wrappings and then called as external programs. Since they would still reference parameters as $1, $2 etc, it just worked: function bodies and standalone sh scripts had the same interface! Such a clever idea to avoid managing an interpreted call stack in the parent.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: