Skip to content
/ server Public

Comments

MDEV-15549 - wsrep_sst_common: fix per shellcheck#645

Merged
janlindstrom merged 1 commit intoMariaDB:10.0-galerafrom
grooverdan:10.0-wsrep_sst_common_bashism
Jul 19, 2018
Merged

MDEV-15549 - wsrep_sst_common: fix per shellcheck#645
janlindstrom merged 1 commit intoMariaDB:10.0-galerafrom
grooverdan:10.0-wsrep_sst_common_bashism

Conversation

@grooverdan
Copy link
Member

POSIX shell support in 10.0-galera would require f16ead5 however this shellcheck component wasn't included.

shellcheck -s sh wsrep_sst_common.sh

In wsrep_sst_common.sh line 258:
[ -n $3 ] && reval=$3
^-- SC2070: -n doesn't work with unquoted arguments. Quote or use [[ ]].
^-- SC2086: Double quote to prevent globbing and word splitting.

I submit this under the MCA.

shellcheck -s sh wsrep_sst_common.sh

In wsrep_sst_common.sh line 258:
        [ -n $3 ] && reval=$3
             ^-- SC2070: -n doesn't work with unquoted arguments. Quote or use [[ ]].
             ^-- SC2086: Double quote to prevent globbing and word splitting.
@svoj svoj added this to the 10.0 milestone Mar 12, 2018
@svoj svoj changed the title wsrep_sst_common: fix per shellcheck MDEV-15549 - wsrep_sst_common: fix per shellcheck Mar 12, 2018
@svoj
Copy link
Contributor

svoj commented Mar 12, 2018

Hi @grooverdan,

Thanks for your contribution. Corresponding JIRA task: https://jira.mariadb.org/browse/MDEV-15549

This task was added to 10.3 backlog.

Thanks,
Sergey

@svoj svoj assigned janlindstrom and unassigned SachinSetiya May 3, 2018
Copy link
Contributor

@janlindstrom janlindstrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you need double quote inside [] but not in reval= ?

@grooverdan
Copy link
Member Author

because assignment isn't shell expanded

$ cat /tmp/x.sh
#!/bin/sh
a=$1
echo $1
$ /tmp/x.sh "a; ls"
a; ls

Expressions are:

$ cat /tmp/x.sh
#!/bin/sh
[ -n $1 ] && echo onehorse
[ -n "$1" ] && echo twohorse

$ /tmp/x.sh dog
onehorse
twohorse

$ /tmp/x.sh ''
onehorse

$ /tmp/x.sh '"" || 1'
/tmp/x.sh: line 2: [: too many arguments
twohorse

So lets protect against all the odd things that could be used in config file variables.

@janlindstrom janlindstrom merged commit 71e0ba4 into MariaDB:10.0-galera Jul 19, 2018
@grooverdan grooverdan deleted the 10.0-wsrep_sst_common_bashism branch July 19, 2018 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants