DemocracyFTW2 12 hours ago

> Where does mkcd come from? Multiple discovery is likely because the core idea is so simple.

Indeed, I have my own `mkcd` implementation:

    mkcd () {
      mkdir -p $@ && cd ${@:$#}
    }
Curiously I can't find where I (?) implemented it, and reading the source I realize how bash scripting is both ingenious and terrifying at the same time. I have so many questions. Where is this source recorded, what incantation tell me that? Are missing quotes around `$@` OK? I know / think / believe / heard someone say it's a modern replacement for `$*` and that one did need quotes? What is the `${@:$#}` part doing? Is it worth to save all of 7 (seven!1!) bytes so people can be so much faster by not having to type for example

    mkcd ( path ) {
      mkdir -p $path && cd $path
    }
Why is bash such a mess?

Edit: shellcheck tells me to write `"$@"` and `"${@:$#}"` so quotes are indeed needed. Why is bash such a mess? Why?

Edit: For posterity, `type mkcd` is what I'm looking for; its output is quite helpful:

    $ mkcd is a shell function from /home/REDACTED/.oh-my-zsh/lib/functions.zsh
...where I indeed find

    # mkcd is equivalent to takedir
    function mkcd takedir() {
      mkdir -p $@ && cd ${@:$#}
    }
so obviously it's not my implementation (although I 'know' I 'invented' it at some point). The source has no quotes around `$@` although similar functions above and below this one do use quotes. However I just tried

    mkcd '/tmp/what ever spaces'   
and this worked fine.