# HG changeset patch # User "Yann E. MORIN" # Date 1311530893 -7200 # Node ID 7e0af0188fc318c51b0451710e47b72ea5f8197b # Parent 8e793413baae5a5705eab7f89545a44d2c063146 functions: add new helpers that create a dir and cd/pushd into it A lot of places are currently doing: mkdir -p foo/bar cd foo/bar Or even: mkdir -p foo/bar pushd foo/bar [...] popd Provide both wrapper to ease doing this. Signed-off-by: "Yann E. MORIN" diff -r 8e793413baae -r 7e0af0188fc3 scripts/functions --- a/scripts/functions Sun Jul 24 19:24:02 2011 +0200 +++ b/scripts/functions Sun Jul 24 20:08:13 2011 +0200 @@ -323,6 +323,22 @@ popd >/dev/null 2>&1 } +# Create a dir and cd or pushd into it +# Usage: CT_mkdir_cd +# CT_mkdir_pushd +CT_mkdir_cd() { + local dir="${1}" + + mkdir -p "${dir}" + cd "${dir}" +} +CT_mkdir_pushd() { + local dir="${1}" + + mkdir -p "${dir}" + CT_Pushd "${dir}" +} + # Creates a temporary directory # $1: variable to assign to # Usage: CT_MktempDir foo