pt-stalk expr on FreeBSD
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
There is a difference on how expr works on Linux and BSD:
[root@freebsd ~]# ./percona-
expr: illegal option -- -
expr: usage: expr [-e] expression
./percona-
expr: illegal option -- -
expr: usage: expr [-e] expression
./percona-
expr: illegal option -- -
expr: usage: expr [-e] expression
./percona-
2015_09_08_22_42_04 Starting ./percona-
2015_09_08_22_42_04 Check results: status(
2015_09_08_22_42_05 Check results: status(
2015_09_08_22_42_07 Check results: status(
2015_09_08_22_42_08 Check results: status(
^C2015_
find: -warn: unknown primary or operator
2015_09_08_22_42_08 All subprocesses have finished
2015_09_08_22_42_08 Exiting because OKTORUN is false
2015_09_08_22_42_08 ./percona-
On simpler tests:
[root@freebsd ~]# opt="--daemonize"
[root@freebsd ~]# expr "$opt" : "\-"
expr: illegal option -- -
expr: usage: expr [-e] expression
[root@freebsd ~]# bash --version
GNU bash, version 4.3.0(1)-release (amd64-
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[revin@acme ~]$ opt="--daemonize"
[revin@acme ~]$ expr "$opt" : "\-"
1
[revin@acme ~]$ bash --version
GNU bash, version 4.2.46(1)-release (x86_64-
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
If I change, how the expression is handled
[revin@acme ~]$ opt=--daemonize
[revin@acme ~]$ expr "$(echo $opt|sed 's/\-/\\-/g')" : '\\-'
2
[root@freebsd ~]# opt=--daemonize
[root@freebsd ~]# expr "$(echo $opt|sed 's/\-/\\-/g')" : '\\-'
2
[root@freebsd ~]#
Here are the patches you can try to make it work on pt-stalk:
419 if [ $(expr "$opt" : "\-") -eq 0 ]; then
419 if [ $(expr "$(echo $opt|sed 's/\-/\\-/g')" : '\\-') -eq 0 ]; then
412 if [ $# -eq 0 ] || [ $(expr "$opt" : "\-") -eq 1 ]; then
412 if [ $# -eq 0 ] || [ $(expr "$(echo $opt|sed 's/\-/\\-/g')" : '\\-') -gt 1 ]; then
Thank you for the report and contribution.
Verified as described.