Bug 33714 - shell-ini-config добавляет пустую строку в конец файла
Summary: shell-ini-config добавляет пустую строку в конец файла
Status: CLOSED FIXED
Alias: None
Product: Sisyphus
Classification: Development
Component: libshell (show other bugs)
Version: unstable
Hardware: all Linux
: P3 minor
Assignee: Alexey Gladkov
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-01 18:59 MSK by manowar@altlinux.org
Modified: 2017-08-03 13:04 MSK (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description manowar@altlinux.org 2017-08-01 18:59:23 MSK
При удалении одной или всех переменных из секции в конец файла добавляется пустая строка. Новые секции и переменные добавляются уже *после* этой путой строки. В результате, после многих вызовов ini_config_set и ini_config_del, файл получается очень разряженным — человеку его потом редактировать крайне неудобно.

$ echo '[mysection]' >test.ini
$ echo 'myvar = myval' >>test.ini
$ cat test.ini 
[mysection]
myvar = myval
$ . shell-ini-config
$ ini_config_del test.ini mysection
$ cat test.ini 
[mysection]

$ rpm -qf /bin/shell-ini-config
libshell-0.4.1-alt1


Workaround:
Помогает sed -i -e '$ { /^$/ d }' "$CONFIG" после каждого вызова ini_config_del.
Comment 1 Alexey Gladkov 2017-08-02 12:11:11 MSK
Хорошо подметили. Я нашёл ещё одну багу в этом модуле. Спасибо.
Comment 2 Repository Robot 2017-08-03 13:04:34 MSK
libshell-0.4.3-alt1 -> sisyphus:

Thu Aug 03 2017 Alexey Gladkov <legion@altlinux.ru> 0.4.3-alt1
- New version (0.4.3).
- shell-ini-config changes:
  + Do not add new line after deletion (ALT#33714).
  + Preserve spaces in comments.
- shell-git-config changes:
  + Add includeIf support.
- shell-var changes:
  + Add shell_var_is_number.