aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/etc/shinit
diff options
context:
space:
mode:
authorJeffery To <jeffery.to@gmail.com>2019-05-03 02:24:27 +0800
committerPetr Štetiar <ynezz@true.cz>2020-03-01 21:35:59 +0100
commit12020f8a95d21547bd7d7fd1fef9cdecf2892803 (patch)
treedb9a4a36e04807b0b24b542ea21b25725bd4bc82 /package/base-files/files/etc/shinit
parent2c3c83e40bf102ee25b352298d54fc0f86372e4f (diff)
downloadupstream-12020f8a95d21547bd7d7fd1fef9cdecf2892803.tar.gz
upstream-12020f8a95d21547bd7d7fd1fef9cdecf2892803.tar.bz2
upstream-12020f8a95d21547bd7d7fd1fef9cdecf2892803.zip
base-files: Add /etc/shinit for non-login shell init
Because /etc/profile (and ~/.profile) are read by login shells only, aliases and functions defined there are not available to non-login shells, e.g. when using screen or tmux. If the ENV environment variable exists (exported by /etc/profile or ~/.profile) and references an existing file, then all interactive shells (login or non-login) will read that file as well. This sets the ENV environment variable in /etc/profile, pointing to /etc/shinit. This also adds /etc/shinit, which: * Contains alias and function definitions originally in /etc/profile * Sources /etc/mkshrc if the user is using mksh (also originally in /etc/profile), as /etc/mkshrc is meant for all interactive shells * Sources ~/.mkshrc if the user is using mksh, to compensate for the fact that mksh will not read ~/.mkshrc if ENV is set * Sources ~/.shinit if the user is not using mksh This also removes the shebang from /etc/profile, as the file is sourced, not executed. Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Diffstat (limited to 'package/base-files/files/etc/shinit')
-rw-r--r--package/base-files/files/etc/shinit21
1 files changed, 21 insertions, 0 deletions
diff --git a/package/base-files/files/etc/shinit b/package/base-files/files/etc/shinit
new file mode 100644
index 0000000000..6b715c1ef9
--- /dev/null
+++ b/package/base-files/files/etc/shinit
@@ -0,0 +1,21 @@
+[ -x /bin/more ] || alias more=less
+[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi
+
+alias ll='ls -alF --color=auto'
+
+[ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc
+
+[ -x /usr/bin/arp -o -x /sbin/arp ] || arp() { cat /proc/net/arp; }
+[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
+
+service() {
+ [ -f "/etc/init.d/$1" ] || {
+ echo "service "'"'"$1"'"'" not found, the following services are available:"
+ ls "/etc/init.d"
+ return 1
+ }
+ /etc/init.d/$@
+}
+
+[ -n "$KSH_VERSION" -o \! -s "$HOME/.shinit" ] || . "$HOME/.shinit"
+[ -z "$KSH_VERSION" -o \! -s "$HOME/.mkshrc" ] || . "$HOME/.mkshrc"