Sample Header Ad - 728x90

Expansion of tilde in zsh

16 votes
2 answers
8478 views
I stumbled upon this behavior of zsh when using FreeBSD: % dd if=/dev/zero bs=1M count=1 of=~/test2 dd: failed to open '~/test2': No such file or directory This really confused me because the same thing works just fine in bash. I can touch files using tilde in zsh, and then ls them: % touch ~/test2 % ls ~/test2 /home/christoph/test2 At first, I assumed that zsh doesn't realize that there comes a path after of= so it didn't expand ~. But autocompleting file names works just fine. In fact, if use an existing file name, begin its path with ~, and then hit Tab at some point, the path gets expanded in the command I'm typing in. Why does zsh pass ~/test2 to dd, not /home/christoph/test2? zsh behaves the same on Linux. In fact, I executed these commands above and copied their outputs on a Linux machine.
Asked by UTF-8 (3377 rep)
Jun 26, 2017, 06:13 PM
Last activity: Jun 26, 2024, 12:49 PM