ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Ivan Zakharyaschev <imz@altlinux.ru>
To: ALT Devel discussion list <devel@altlinux.ru>
Subject: Re: [devel] Re: I: console-tools-0.2.3-ipl14.1mdk
Date: Tue, 5 Nov 2002 19:39:36 +0300 (MSK)
Message-ID: <Pine.LNX.4.44L.0211051934330.2080-100000@arrakis.zephyrous> (raw)
In-Reply-To: <20021105091441.GD14323@basalt.office.altlinux.ru>

	Hello!

On Tue, 5 Nov 2002, Dmitry V. Levin wrote:

> > А чем твоя проверка на интерактивность лучше PS1 (PS1 я нашёл в
> info
> > bash и успокоился, уверенный в том, что это корректно).
>
> Такая же проверка есть в /etc/bashrc.

Я ещё раз заглянул на ту же страницу -- там написаны оба варианта, так
что, наверное, больщой разницы нет. $- немного понятнее.

В скрипте Mandrake есть ещё такая проверка:

# bash sets the $- variable, and puts 'c' in it if it is a
non-interactive
# shell
# For other shells, I assume $- is not available
if [ "$SHELL" = "/bin/bash" ]; then
		if echo $- | grep 'c' >/dev/null; then
				return  #non-interactive
		fi
fi

Есть ли какие-нибудь соображения, нужна ли она в дополнение к уже
имеющейся? i и c друг друга не исключают:

$ sh -ic 'echo $-'
himBc


А вот отрывок из bash.info, про который я говорил:

Is this Shell Interactive?
--------------------------

   To determine within a startup script whether or not Bash is running
interactively, test the value of the `-' special parameter.  It
contains `i' when the shell is interactive.  For example:

     case "$-" in
     *i*)	echo This shell is interactive ;;
     *)	echo This shell is not interactive ;;
     esac

   Alternatively, startup scripts may examine the variable `PS1'; it is
unset in non-interactive shells, and set in interactive shells.  Thus:

     if [ -z "$PS1" ]; then
             echo This shell is not interactive
     else
             echo This shell is interactive
     fi




-- 
С наилучшими пожеланиями,
Иван Захарьящев, Москва



  reply	other threads:[~2002-11-05 16:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-05  9:14   ` Dmitry V. Levin
2002-11-05 16:39     ` Ivan Zakharyaschev [this message]
2002-11-05 17:38       ` Dmitry V. Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44L.0211051934330.2080-100000@arrakis.zephyrous \
    --to=imz@altlinux.ru \
    --cc=devel@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git