From: "Arcady V. Ivanov" <arc@help0.ru> To: community@altlinux.ru Subject: Re: [Comm] Вопрос по bash Date: Tue, 04 May 2004 12:36:53 +1300 Message-ID: <4096D795.5000900@help0.ru> (raw) In-Reply-To: <20040503174702.GA2229@sirius.home> Sergey Vlasov пишет: >On Mon, May 03, 2004 at 02:30:07PM +1300, Arcady V. Ivanov wrote: > > >>Вот тут разглядываю конструкцию в /etc/bashrc и не могу въехать: >>--------------------- >># Are we an interactive shell? >>if [ -z "${-##*i*}" ]; then >>--------------------- >> >>${-##*i*} - что означает и в каких случаях этот if срабатывает. >> >> > >Переменная $- содержит набор установленных опций shell (см. описание >set builtin в man bash). Конструкция ${NAME##PATTERN} раскрывается в >значение $NAME, в котором из начала удалена подстрока максимально >возможной длины, соответствующая шаблону PATTERN. Т.е. в данном >случае, если в $- не содержалась буква i, в результате получится >исходное значение $-; если содержалась - получится пустая строка; >далее [ -z STR ] проверяет именно на пустую строку. > > Спасибо. Теперь понял, что "-" это переменная. И наконец-то прочитал об этом в описании bash :-) . >Кстати, эта конструкция содержит ошибку - условие выполнится не только >при установленной опции i (для interactive shell), но и в том случае, >когда в $- пустая строка (не установлена ни одна опция). Нужно либо >добавлять && [ -n "$-" ], либо написать вместо этого case. > Эта строка, кстати, из /etc/bashrc Master 2.2 -- Sincerely yours. Arcady. http://www.help0.ru --------------------------------- Linux forever! No alternatives!!!
prev parent reply other threads:[~2004-05-03 23:36 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-05-03 1:30 Arcady V. Ivanov 2004-05-03 17:47 ` Sergey Vlasov 2004-05-03 23:36 ` Arcady V. Ivanov [this message]
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=4096D795.5000900@help0.ru \ --to=arc@help0.ru \ --cc=community@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 Community general discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/community/0 community/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 community community/ http://lore.altlinux.org/community \ mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com public-inbox-index community Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.community AGPL code for this site: git clone https://public-inbox.org/public-inbox.git