Help us understand the problem. What is going on with this article?

mkdir したディレクトリに cd する

More than 5 years have passed since last update.

こういうのはよく見掛けるけど、 mkdir のオプションが固定だったり、
- で始まるディレクトリが扱えなかったりして悲くなったので作ってみた。
(ってのは後付けで、とりあえず Qiita に何か書いてみたかった)

function mkcdir() {
    mkdir "$@" || return $?

    local arg got_end_option=0
    for arg in "$@"; do
        case "$arg" in
            --)
                got_end_option=1
                continue
                ;;
            -*)
                ((1 == $got_end_option)) && break
                continue
                ;;
            *)
                break
                ;;
        esac
    done
    cd -- "$arg"
}
relaido
動画広告プラットフォーム「relaido」を開発・運営するvideo ad tech company
https://relaido.co.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away