[Lunar-commits] <moonbase-core> lunar: improve lcd alias
v4hn
me at v4hn.de
Sat Nov 23 18:22:36 CET 2013
commit 737f6667e1d3d3e864bddbbf88e05271b61949b0
Author: v4hn <me at v4hn.de>
Date: Fri, 15 Nov 2013 17:32:35 -0800
URL: https://github.com/lunar-linux/moonbase-core/commit/737f6667e1d3d3e864bddbbf88e05271b61949b0
lunar: improve lcd alias
This now checks whether the section really exists
before trying to cd there. This removes ugly "$MOONBASE//$MODULE"
folder does not exist error message
---
system/lunar/profile.d/lunar.rc | +13/-4
1 file changed, 13 insertions(+), 4 deletions(-)
--- a/system/lunar/profile.d/lunar.rc
+++ b/system/lunar/profile.d/lunar.rc
@@ -171,10 +171,19 @@ alias lwtf="lvu what"
complete -F _lunar_comp_modules lwtf
function lcd(){
- [[ -z "$1" || "$1" = "." ]] &&
- cd "$(lsh 'echo $MOONBASE')" ||
- cd "$(lsh "echo \$MOONBASE/\$(find_section $1)/$1")"
- return 0
+ local mb section
+ mb="$(lsh 'echo $MOONBASE')"
+ if [[ -z "$1" || "$1" = "." ]]; then
+ cd "$mb"
+ else
+ section="$(lsh find_section "$1")"
+ if [[ -z "$section" ]]; then
+ echo "$0: lcd: No such module in moonbase" >&2
+ return 1
+ else
+ cd "$mb/$section/$1"
+ fi
+ fi
}
complete -F _lunar_comp_modules lcd
More information about the Lunar-commits
mailing list