ALT Linux Sisyphus discussions
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: ALT Linux Sisyphus mailing list <sisyphus@lists.altlinux.org>
Subject: Re: [sisyphus] Про взаимодействие bash с внешней libreadline
Date: Tue, 17 Dec 2013 04:48:58 +0400
Message-ID: <20131217004857.GA5380@altlinux.org> (raw)
In-Reply-To: <20131216161623.GE16548@newmaster.mivlgu.local>

[-- Attachment #1: Type: text/plain, Size: 2288 bytes --]

On Mon, Dec 16, 2013 at 08:16:23PM +0400, Sergey Vlasov wrote:
> На самом деле, возможно, это баг в bash (точнее, во взаимодействии bash с
> внешней библиотекой libreadline).
> 
> Дело в том, что в libreadline есть функция sh_set_lines_and_columns(),
> которая как раз и добавляет в окружение текущего процесса переменные LINES
> и COLUMNS:
> 
>   http://git.altlinux.org/gears/r/readline.git?p=readline.git;a=blob;f=readline/shell.c;h=346f8113d43d742191f34f431d55e94316e4431d;hb=bc8ee94c5760cc286148d7ab25f2606c0eeeb52a#l121
> 
> Однако ближе к началу файла shell.c есть следующий комментарий:
> 
>  88 /* All of these functions are resolved from bash if we are linking readline
>  89    as part of bash. */
> 
>   http://git.altlinux.org/gears/r/readline.git?p=readline.git;a=blob;f=readline/shell.c;h=346f8113d43d742191f34f431d55e94316e4431d;hb=bc8ee94c5760cc286148d7ab25f2606c0eeeb52a#l88
> 
> И действительно, в самом bash тоже определяется функция
> sh_set_lines_and_columns():
> 
>   http://git.altlinux.org/gears/b/bash.git?p=bash.git;a=blob;f=bash/variables.c;h=1c782534e22d77e492cb66cad6d8666c9a911e23;hb=ab284e13150cb2edf3345256c6ddd919babf3a24#l864
> 
> В отличие от реализации в libreadline, функция из bash использует не
> setenv(), а внутреннюю функцию bash bind_variable(), которая устанавливает
> внутреннюю переменную shell, по умолчанию не экспортирующуюся в дочерние
> процессы; именно такое поведение можно наблюдать сейчас в zsh - в скриптах
> можно использовать переменные $LINES и $COLUMNS, но zsh не передаёт эти
> переменные другим процессам, если не выполнить export явно.
> 
> Однако в ALT пакеты bash и libreadline собраны таким образом, что при
> вызове sh_set_lines_and_columns() из функций libreadline всегда вызывается
> реализация этой функции внутри libreadline - перекрытие её реализацией из
> bash, предполагавшееся разработчиками, не выполняется.

Вот уж действительно peculiar design.

Видимо, придется превратить все функции sh_*, определенные в файле
readline/shell.c, в weak alias'ы, и экспортировать их из libreadline.
Другого способа реализовать задуманное автором перекрытие функций
при использовании динамической линковки с libreadline я не вижу.

http://git.altlinux.org/tasks/110622/


-- 
ldv

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2013-12-17  0:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-14 21:42 [sisyphus] Про htop Alexei V. Mezin
2013-12-15 11:20 ` Alexei V. Mezin
2013-12-15 11:23   ` Serg A. Kotlyarov
2013-12-15 12:03     ` Anton Gorlov
2013-12-15 13:00     ` Alexei V. Mezin
2013-12-15 13:22       ` Alexei V. Mezin
2013-12-15 13:51         ` Alexey Borisenkov
2013-12-15 13:56           ` Alexey Borisenkov
2013-12-15 14:47         ` Serg A. Kotlyarov
2013-12-15 16:42         ` Sergey
2013-12-16  8:13           ` Sergey
2013-12-15 18:09         ` Michael Shigorin
2013-12-15 18:23         ` Anton Gorlov
2013-12-16 16:16         ` Sergey Vlasov
2013-12-17  0:48           ` Dmitry V. Levin [this message]
2013-12-17  9:20             ` [sisyphus] Про взаимодействие bash с внешней libreadline Anton Gorlov
2013-12-17  9:27               ` Anton Gorlov
2013-12-19 17:03               ` Alexei V. Mezin
2013-12-19 19:36                 ` Anton Gorlov

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=20131217004857.GA5380@altlinux.org \
    --to=ldv@altlinux.org \
    --cc=sisyphus@lists.altlinux.org \
    /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 Sisyphus discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/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 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \
		sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru
	public-inbox-index sisyphus

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


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