Bjartur Thorlacius writes: > > On 2/24/11, Jim Meyering <j...@meyering.net> wrote: > > Bjartur Thorlacius wrote: > >>> Maybe we should modify tac to add the -z option. Would you care to > >> write a patch? > >> It would be redundant, as tac -s $'\0' is equivalent.
Note that a $'\0' argument in a shell command line is exactly equivalent to an empty string, since it must be passed from the shell to the program using execve() which takes NUL-terminated strings. There is no way to run a program with an actual NUL byte contained in one of its arguments. execve will stop copying at the NUL, and even if it didn't, the new program receives its arguments in int argc, char **argv form so how is it supposed to know that there's a NUL in there that's not a terminator? This limitation can't be avoided. It's not just a C language thing. The execve interface is based on NUL-terminated strings at the asm level too. If tac -s $'\0' did something different from tac -s '', it could only have been a shell builtin. (Assuming the shell supported the $'...' notation at all) -- Alan Curry