2015/06/04: Chaining commands

One of the ideas present in the UNIX world is that programs should do one thing and do it properly. Focusing on one thing means deliberately ignoring others; why should every program know care about "nice" values, ways of allowing an interactive user to conveniently enter commands, etc?

So there are a lot of programs modifying (by wrapping) an existing one by taking care of one of those aspects. I'm thinking of programs like nice(1), env(1), rlwrap(1), script(1). Given that the standard way of calling a command is to pass it a list of strings, there is also an easy way to combine such commands. Each can take a self-delimiting prefix of the list and do an execve(2) on the remaining part of the list. This allows long chains like nice -n 20 script foo.script env FOO=BAR .... The FreeBSD version of script(1) switched to this calling convention in 1997 (svn commit 32083); I always wonder how the version of script(1) that is part of util-linux got its -c option asking for more quoting than necessary.



Cross-referenced by: