Hacker News new | past | comments | ask | show | jobs | submit login

Ok, if that actually works, that's amazing. Wow.



It works because of the general principle that I mentioned here:

https://news.ycombinator.com/item?id=15249370

The shell (not the command) is the one expanding those metacharacters, so (within limits), in:

cmd < file

or

< file cmd

where you put that piece (< file) on the line does not matter, because the actual command cmd never sees the redirection at all - it is done [1] by the time the command starts. The cmd command will only see the command line arguments (other than redirections) and options (arguments that start with a dash). Even expansion of $ and other sigils (unless quoted) happens before the command starts.

[1] I.e. the shell and kernel set up the standard input of the command to be connected to the file opened for reading (in the case of < file).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: