diff options
author | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2011-07-24 20:08:13 +0200 |
---|---|---|
committer | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2011-07-24 20:08:13 +0200 |
commit | c0475188cbb0ff40be98652fb3b422781495dfbd (patch) | |
tree | 76f3de2ff18a32f1edfa1752262d369ef7920020 /scripts | |
parent | b990202ced6f3f64b9daf91fa5cec638714cfff6 (diff) | |
download | crosstool-ng-c0475188cbb0ff40be98652fb3b422781495dfbd.tar.gz crosstool-ng-c0475188cbb0ff40be98652fb3b422781495dfbd.tar.bz2 crosstool-ng-c0475188cbb0ff40be98652fb3b422781495dfbd.zip |
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" <yann.morin.1998@anciens.enib.fr>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/functions | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/functions b/scripts/functions index 95b74156..cc218991 100644 --- a/scripts/functions +++ b/scripts/functions @@ -323,6 +323,22 @@ CT_Popd() { popd >/dev/null 2>&1 } +# Create a dir and cd or pushd into it +# Usage: CT_mkdir_cd <dir/to/create> +# CT_mkdir_pushd <dir/to/create> +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 |