diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-11-21 10:39:24 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2010-11-21 10:40:28 -0700 |
commit | ab1cf46448eaa4ae6cce3edcf013da73bd41c1ea (patch) | |
tree | 97b3ae55b1822105e4adc93482bc2947cbb7bf78 /classes | |
parent | 0bf3d4989bfe69df501f6392f7ef2065183ec0d0 (diff) | |
download | openembedded-ab1cf46448eaa4ae6cce3edcf013da73bd41c1ea.tar.gz |
utils.bbclass: add dirs/pushd/popd
These can be useful, and even necessary in some tasks, yet are bash, so let's
ensure they're available so we can avoid the /bin/sh is bash requirement in
the future.
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'classes')
-rw-r--r-- | classes/utils.bbclass | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/classes/utils.bbclass b/classes/utils.bbclass index 4cc68963ef..2fa6204bfa 100644 --- a/classes/utils.bbclass +++ b/classes/utils.bbclass @@ -434,3 +434,23 @@ def base_set_filespath(path, d): for o in overrides.split(":"): filespath.append(os.path.join(p, o)) return ":".join(filespath) + +# These directory stack functions are based upon the versions in the Korn +# Shell documentation - http://docstore.mik.ua/orelly/unix3/korn/ch04_07.htm. +dirs() { + echo "$_DIRSTACK" +} + +pushd() { + dirname=$1 + cd ${dirname:?"missing directory name."} || return 1 + _DIRSTACK="$PWD $_DIRSTACK" + echo "$_DIRSTACK" +} + +popd() { + _DIRSTACK=${_DIRSTACK#* } + top=${_DIRSTACK%% *} + cd $top || return 1 + echo "$PWD" +} |