Nixers Book Club - Book #1: The UNIX Programming Environment - Community & Forums Related Discussions

Users browsing this thread: 2 Guest(s)
movq
Long time nixers
(05-12-2020, 11:26 AM)venam Wrote: Interestingly, there's a lot of discussion about the efficiency of different ways to do something, especially in conditions.
They advice using ":" built-in instead of calling true as an external command, or to rely on case match instead of external calls, especially within loops. Calling a program was something you had to think about.

It still is, especially if you’re looping over stuff. Forking is damn expensive. Granted, it probably was a lot worse back then, but it’s still one of the first things I try to optimize.

(05-12-2020, 11:26 AM)venam Wrote: One thing that caught my attention that I didn't know about was that you don't have to give for loops a value, it by default loops over `$*`.

It’s actually "$@", the original argument vector (without argv[0]). I wonder why they don’t use "$@" all the time and instead make a lot of examples using $*. (I already made that remark, didn’t I?) Luckily, they explain what "$@" does on page 161.


Messages In This Thread
RE: Nixers Book Club - Book #1: The UNIX Programming Environment - by movq - 05-12-2020, 11:39 AM