be9a70562e
Fixes #13384. Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
146 lines
2.6 KiB
Bash
146 lines
2.6 KiB
Bash
#
|
|
# Administrative startup for /bin/sh
|
|
# Place user customizations in /.profile
|
|
#
|
|
|
|
ps 2>&1 | grep -e $PPID 2>&1 | grep -e $SHELL 2>&1 | grep -q -e $PPID > /dev/null 2>&1
|
|
if [ $? -eq 1 ] ; then
|
|
echo -e "\nWelcome to the Haiku shell.\n"
|
|
export PS1="\w> "
|
|
else
|
|
echo -e "\nSwitching to architecture `getarch`\n"
|
|
export PS1="[`getarch`] \w> "
|
|
fi
|
|
|
|
export USER=`id -un`
|
|
export GROUP=`id -gn`
|
|
|
|
if [ -z $BE_HOST_CPU ]; then
|
|
. /boot/system/boot/SetupEnvironment
|
|
fi
|
|
|
|
export HISTFILESIZE=500
|
|
export HISTCONTROL=ignoredups
|
|
|
|
# Locale
|
|
export LC_MESSAGES=`locale -m`
|
|
export LC_NUMERIC=`locale -f`
|
|
export LC_TIME=`locale -t`
|
|
export LC_COLLATE=$LC_MESSAGES
|
|
export LC_CTYPE=$LC_MESSAGES
|
|
export LC_MONETARY=$LC_NUMERIC
|
|
|
|
alias ls="ls --color=auto"
|
|
alias ll="ls -lA"
|
|
alias la="ls -A"
|
|
alias m="more"
|
|
|
|
test -n "$BASH_VERSION" && shopt -s checkwinsize
|
|
|
|
#
|
|
# and now we include a few useful things...
|
|
#
|
|
|
|
#
|
|
# An almost-ksh compatible `whence' command. This is as hairy as it is
|
|
# because of the desire to exactly mimic ksh.
|
|
#
|
|
# This depends somewhat on knowing the format of the output of the bash
|
|
# `builtin type' command.
|
|
#
|
|
# Chet Ramey
|
|
# chet@ins.CWRU.Edu
|
|
#
|
|
test -n "$KSH_VERSION" || whence()
|
|
{
|
|
local vflag= path=
|
|
|
|
if [ "$#" = "0" ] ; then
|
|
echo "whence: argument expected"
|
|
return 1
|
|
fi
|
|
case "$1" in
|
|
-v) vflag=1
|
|
shift 1
|
|
;;
|
|
-*) echo "whence: bad option: $1"
|
|
return 1
|
|
;;
|
|
*) ;;
|
|
esac
|
|
|
|
if [ "$#" = "0" ] ; then
|
|
echo "whence: bad argument count"
|
|
return 1
|
|
fi
|
|
|
|
returnValue=0
|
|
|
|
for cmd
|
|
do
|
|
if [ "$vflag" ] ; then
|
|
echo $(builtin type $cmd | sed 1q)
|
|
else
|
|
path=$(builtin type -path $cmd)
|
|
if [ "$path" ] ; then
|
|
echo $path
|
|
else
|
|
case "$cmd" in
|
|
*/*) if [ -x "$cmd" ]; then
|
|
echo "$cmd"
|
|
else
|
|
returnValue=1
|
|
fi
|
|
;;
|
|
*) case "$(builtin type -type $cmd)" in
|
|
"") returnValue=1
|
|
;;
|
|
*) echo "$cmd"
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
fi
|
|
fi
|
|
done
|
|
return $returnValue
|
|
}
|
|
|
|
if test -n "$KSH_VERSION"; then
|
|
ps1_pwd() {
|
|
local e=$? d=${PWD:-?}/ p=~
|
|
[[ $p = ?(*/) ]] || d=${d/#$p\//\~/}
|
|
print -nr -- "${d%/}"
|
|
return $e
|
|
}
|
|
PS1=${PS1/'\w'/'$(ps1_pwd)'}
|
|
alias which='whence -p'
|
|
else
|
|
test -n "$BASH_VERSION" || PS1=$(printf '%s' "$PS1" | \
|
|
sed 's/\\w/$PWD/')
|
|
alias which='whence'
|
|
fi
|
|
|
|
function dir {
|
|
ls -lF "$@";
|
|
}
|
|
|
|
for dir in `findpaths -Re B_FIND_PATH_DATA_DIRECTORY profile.d 2> /dev/null`; do
|
|
for i in $dir/*.sh; do
|
|
if [ -r $i ]; then
|
|
. $i
|
|
fi
|
|
done
|
|
unset i
|
|
done
|
|
unset dir
|
|
|
|
if [ -d /etc/profile.d ]; then
|
|
for i in /etc/profile.d/*.sh; do
|
|
if [ -r $i ]; then
|
|
. $i
|
|
fi
|
|
done
|
|
unset i
|
|
fi
|