From: Nicolas Boisselier Date: Tue, 29 Nov 2016 09:32:39 +0000 (+0000) Subject: busybox X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=ddba3f874725b05046a32dd91d4a2c1b16b5d7f8;p=nb.git busybox --- diff --git a/etc/profile b/etc/profile index 0f66d78d..42e94142 100755 --- a/etc/profile +++ b/etc/profile @@ -62,6 +62,7 @@ else #echo $NB_CURRENT_DIR; return [ -e "$NB_CURRENT_DIR/profile.d/functions" ] && . "$NB_CURRENT_DIR/profile.d/functions" + echo $(realpath $NB_CURRENT_DIR/..) export NB_ROOT=$(realpath $NB_CURRENT_DIR/.. 2>/dev/null) [ -n "$NB_DEBUG" ] && $NB_DEBUG "NB_ROOT=$NB_ROOT" diff --git a/etc/profile.d/envs b/etc/profile.d/envs index 220c48e4..77bb4e29 100644 --- a/etc/profile.d/envs +++ b/etc/profile.d/envs @@ -70,12 +70,11 @@ case "$BASH" in */sh) SHELL_NAME=sh ;; */bash) SHELL_NAME=bash ;; *) - case "$(realpath /bin/grep)" in - *busybox*) SHELL_NAME="busybox" ;; - *) - [ -n "$ZSH_NAME" ] && SHELL_NAME=zsh - ;; - esac + if ls --help 2>&1 | grep -qm1 ^BusyBox; then + SHELL_NAME="busybox" + elif [ -n "$ZSH_NAME" ]; then + SHELL_NAME=zsh + fi ;; esac export SHELL_NAME diff --git a/etc/profile.d/functions b/etc/profile.d/functions index ce826dde..317eb8da 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -160,18 +160,18 @@ env_add_path() { [ -z "$env_value" ] || echo "$env_value" } +if !which realpath 2>/dev/null; then realpath() { - if [ -x /usr/bin/realpath ]; then - /usr/bin/realpath "$1" - elif which perl &> /dev/null; then + if which perl &> /dev/null; then perl -MFile::Spec -MCwd -e 'print File::Spec->rel2abs( Cwd::abs_path($ARGV[0]) )."\n" if -e $ARGV[0]' "$1" else case "$OSTYPE" in - darwin*) readlinks "$1" ;; - *) readlinks -f "$1" ;; + darwin*) readlink "$1" ;; + *) readlink -f "$1" ;; esac fi } +fi ascii() {