3 ms·
Thanks for taking the time to comment. Multiple arguments could be added if you want that. I personally do not need it as I search the cmdline patterns I need
by _c_ 10y ago
Thanks for taking the time to comment.
Multiple arguments could be added if you want that. I personally do not need it as I search the cmdline patterns I need without using spaces. I use dots instead. Quick and dirty.
I write 100's of these small scripts for my own use only so I have my own style, peculiar as it may be. I never need indentation because I always keep scripts short; I only use it occasionally and randomly.
I do not use -e with sed, unless I'm using branches or loops.
The execs seem superfluous but actually make a difference, at least on the UNIX I use. Try it with and without and see if you notice.
All my scripts are portable to Bash, but they're also portable to the most basic of Bourne-compatible shells too. I do not use Bash.
- LukeShu 10y agoWhat shell are you using? I could see a naive shell forking twice without exec, but I don't know of a shell that does that. Exec just says "don't fork(3) before calling exec(3)", but, but inside of a pipeline like that, it shouldn't fork again anyway. I have tried it with and without.
- _c_ 10y agoIn theory it should not make a difference but my scripts seem to run faster when I use exec after pipe. Normally I would only add exec to the last command in the script, as djb does. But then I started experimenting with using it after pipes. If you or anyone can explain why this could make scripts "seem" to execute faster, I would be grateful. Here's the shell source: ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-release-7/src/bin/sh Incidentally, have you ever tried execlineb? I use that sometimes too.