From 22cac80359f0f58a2ef2e4b55b0daeca1dc0e074 Mon Sep 17 00:00:00 2001 From: LAN-TW Date: Mon, 9 Jan 2012 23:43:39 +0800 Subject: bash_include: 以更可靠的方式得知是否為互動式 shell、超級使用者提醒功能 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash_include | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'bash_include') diff --git a/bash_include b/bash_include index 8561a65..dbb94a4 100644 --- a/bash_include +++ b/bash_include @@ -1,14 +1,15 @@ #!/bin/bash # -# +# /home/lantw44/.bash_include # # -- UTF-8 -- # -if tty -s; then interactive_shell=1; fi +#### if tty -s; then interactive_shell=1; fi +if [ "`echo "$-" | grep "i" `" ]; then interactive_shell=1; fi [ "$interactive_shell" ] && echo "Running .bash_include" -[ "$interactive_shell" ] && default_tty_setting=`stty -g` +[ "$interactive_shell" ] && default_tty_setting="`stty -g`" # Internal Variables @@ -794,5 +795,11 @@ shopt -s checkhash shopt -s cmdhist shopt -s mailwarn -[ "$interactive_shell" ] && echo "Done" +[ "$interactive_shell" ] && { + echo "Done" + if [ "$UID" = "0" ] || [ "$EUID" = "0" ] + then + printf "\nNote: You may be \e[1;32mprivileged\e[m now!\n\n" + fi +} -- cgit