From 061365a80c9291fddb41c2ccd7132272b9930847 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 29 Oct 2021 15:40:56 +0200 Subject: [rootfs-stage32] /etc/profile: Only source bashrc on bash --- core/rootfs/rootfs-stage32/data/etc/profile | 43 +++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'core/rootfs') diff --git a/core/rootfs/rootfs-stage32/data/etc/profile b/core/rootfs/rootfs-stage32/data/etc/profile index 125e7195..b50b1693 100644 --- a/core/rootfs/rootfs-stage32/data/etc/profile +++ b/core/rootfs/rootfs-stage32/data/etc/profile @@ -4,11 +4,31 @@ export UID=`id -u` 2> /dev/null +# Stuff we might wanna know +PWENT= +[ -n "$UID" ] && PWENT=`getent passwd "$UID"` +[ -z "$PWENT" ] && [ -n "$USER" ] && PWENT=`getent passwd "$USER"` +if [ -n "$PWENT" ]; then + export USER=`echo "$PWENT" | awk -F ':' '{print $1}'` + export GID=`echo "$PWENT" | awk -F ':' '{print $4}'` + export HOME=`echo "$PWENT" | awk -F ':' '{print $6}'` + export GROUP=`id -gn` + export LOGNAME=$USER + export HOSTNAME=`hostname` +fi +unset PWENT + # If running interactively, then: -if [ "$PS1" ]; then +if [ "${PS1-}" ]; then - if [ "$BASH" ]; then + if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then export PS1="[\u@\h \W]\\$ " + if [ -s /etc/bash.bashrc ]; then + . /etc/bash.bashrc + fi + if [ -s "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi else if [ "$UID" -eq 0 ]; then export PS1='# ' @@ -22,24 +42,10 @@ if [ "$PS1" ]; then export PAGER='/bin/less' export EDITOR='/bin/vi' export INPUTRC=/etc/inputrc - #export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile export TERMINFO='/lib/terminfo' fi -# Stuff we might wanna know -PWENT= -[ -n "$UID" ] && PWENT=`getent passwd "$UID"` -[ -z "$PWENT" ] && [ -n "$USER" ] && PWENT=`getent passwd "$USER"` -if [ -n "$PWENT" ]; then - export USER=`echo "$PWENT" | awk -F ':' '{print $1}'` - export GID=`echo "$PWENT" | awk -F ':' '{print $4}'` - export HOME=`echo "$PWENT" | awk -F ':' '{print $6}'` - export GROUP=`id -gn` - export LOGNAME=$USER - export HOSTNAME=`hostname` -fi - # set TERM to xterm on SSH sessions [ -n "$SSH_TTY" ] && export TERM=xterm @@ -49,12 +55,9 @@ for i in /etc/profile.d/*.sh ; do . "$i" fi done +unset i # Sourcing /etc/profile.local - please add custom stuff to profile.local # as /etc/profile may be overwritten by system updates test -s /etc/profile.local && . /etc/profile.local -if [ -s "$HOME/.bashrc" ]; then - . "$HOME/.bashrc" -fi - -- cgit v1.2.3-55-g7522