Hey, im back, hope you missed me, this blog is strictly about the English language now (linguistics and stuff). Maybe I’ll start writing about other languages if I ever decide to learn one (like Hindi or French or something else), so don’t hold me to the English thing for too long.

I’ve always had lots of bash aliases, many to just quickly cd to some directory on my machine (the milliseconds saved in typing really helps, trust me).

$ alias dl dt ws # `alias x ...` shows the alias that's set for keyword "x"
alias dl='cd ~/Downloads'
alias dt='cd ~/Desktop'
alias ws='cd ~/workspace'

But today I was going a little too fast (really needed to run my node script) and I noticed a pretty bad bug.

$ dt nod
-bash: cd: too many arguments

There’s 2 problems here: 1) I didn’t press Enter soon enough (should’ve pressed it after I finished typing dt), and 2) I pressed Enter way too soon (should’ve waited until I typed that final e after typing nod). That’s not good.

If it’s not clear what it’s doing: it’s passing an argument, "nod", to that cd alias, and so it’s trying to run:

$ cd ~/Desktop nod
-bash: cd: too many arguments

which doesn’t work because cd only takes 1 directory and isn’t smart enough to just ignore other arguments.

But this is, in fact, the very reason that aliases are thing:

$ alias print-to-stdout='echo'
$ print-to-stdout hello!

so this isn’t actually a bug at all.

I thought I’d make a post anyways because why not at this point.

And if I’m being honest I can’t think of a solution to the problem either, maybe it just doesn’t need one. I’ll just have to make sure I’m pressing Enter more often. Or less often? Idk yet.





cd will actually ignore those extra arguments by default, but for some reason my distribution of Bash has the off by default CD_COMPLAINS flag turned on, so this whole post is even more unnecessary than I had initially intended, sorry.

(This is the Homebrew formula for it; none of those patches it’s pulling in are flipping CD_COMPLAINS, so I have no clue where that’s happening.)

Edit: oops, I’m wrong. It only checks if it’s defined, which it is by default.