Skip to content

fix not enough arguments for shift#48

Closed
rchicoli wants to merge 1 commit intobareos:masterfrom
rchicoli:fix_shell_shift
Closed

fix not enough arguments for shift#48
rchicoli wants to merge 1 commit intobareos:masterfrom
rchicoli:fix_shell_shift

Conversation

@rchicoli
Copy link
Contributor

I was trying to deploy bareos inside docker and for some reasons dbconfig-common wasn't working properly. So after looking inside the maintainer scripts I've found out a quickfix

root@8cf09d5b8649:/var/lib/dpkg# bash -x
info/bareos-database-common.postinst configure
+ set -e
+ . /usr/share/debconf/confmodule
++ '[' '!' '' ']'
++ PERL_DL_NONLAZY=1
++ export PERL_DL_NONLAZY
++ '[' '' ']'
++ exec /usr/share/debconf/frontend info/bareos-database-common.postinst
configure
(config) dbc_go() bareos-database-common configure.
dbc_config() bareos-database-common configure.
dbc_set_dbtype_defaults() .
dbc_register_debconf() .
dbc_read_package_config() .
dbc_preseed_package_debconf() .
dbc_detect_supported_dbtype() pgsql.
dbc_detect_installed_dbtype() pgsql.
_dbc_detect_installed_dbtype() pgsql.
dbc_config() bareos-database-common configure.
dbc_set_dbtype_defaults() pgsql.
dbc_get_app_pass() .
info/bareos-database-common.postinst: 33: shift: can't shift that many
Error cause:

The error comes from the fact that some shells (but not all) detect when there are not enough arguments for shift. In particular, dash considers it a fatal error.

Possible solution:

Test if there are enough remaining arguments:

if [ "$#" -gt 0 ]; then shift; fi

@joergsteffens
Copy link
Member

Thank you for your patch. We have added it to the bareos-15.2 branch as
a040767 which have in the meanwhile been merged to master. I'm wondering, why this issue didn't come up earlier. Also the behavior of dash seems like useless, however this seems to be the case for a number of shells, see http://wiki.bash-hackers.org/commands/builtin/shift.
I'll close this pull request, as the patch is now integrated into Bareos.

franku pushed a commit that referenced this pull request Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants