Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Zsh - possible bug report



Hello,

I have found a behavior of zsh I cannot explain. I don't know if it is a
bug and I hope this is not a duplicate.

$ cat print-argv0.c
> #include <stdio.h>
> int main(int ac, char **av)
> {
> if (ac > 0)
> fputs(av[0], stdout);
> }
> $ cc print-argv0.c
> $ zsh -f -c "exec -a '' ./a.out | hexdump -vC"
> 00000000  9b 9b                                             |..|
> 00000002
> $ zsh -f -c "exec -a \"\" ./a.out | hexdump -vC"
> 00000000  9c 9c                                             |..|
> 00000002


Zsh makes argv[0] hold two bytes, 0x9b9b or 0x9c9c depending on quotes or
double-quotes.
Bash does make argv[0] an empty string.

$ bash -c "exec -a '' ./a.out | hexdump -vC"
> $ bash -c "exec -a \"\" ./a.out | hexdump -vC"
> $


Why does this happen? Is this expected behavior?

Thank you


Messages sorted by: Reverse Date, Date, Thread, Author