News for hackers. Stuff that matters.
Re:URLs in C (2011) by robalni on Wednesday November 04, 2020 @11:19AM (#24990374)
This reminds me of when I tried to write HTML code in bash.

    <html> hi </html> a
This code when run as a bash script reads from a file with name "html" and writes to file "hi". It also reads from file "html" (in the root directory) and writes to a file called "a". The "a" in the end is just to avoid bash errors about unexpected newline.

When I played with this a few years ago I actually discovered a bug in bash. If I had a bash alias with the same name as one of the filenames, bash would do alias expansion on the filename. This bug was triggered by executing a line with two redirection operators before any command.

So if you follow these steps:

    $ alias a='abc xyz'

    $ </ >a
you would get the error (in addition to a file created with name "abc"):

    bash: xyz: command not found
This happened because bash expanded the second line to:

    $ </ >abc xyz
and therefore treated "xyz" as a command (and "abc" and the root directory as filenames). This bug doesn't work anymore in new versions of bash because it has been fixed.

There are no comments on this comment yet.