pt-stalk expr on FreeBSD

Bug #1493634 reported by Jervin R
6
This bug affects 1 person
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-toolkit-2.2.15/bin/pt-stalk --verbose=2 --notify-by-email <email address hidden>,<email address hidden> --threshold=0
expr: illegal option -- -
expr: usage: expr [-e] expression

./percona-toolkit-2.2.15/bin/pt-stalk: line 419: [: -eq: unary operator expected
expr: illegal option -- -
expr: usage: expr [-e] expression

./percona-toolkit-2.2.15/bin/pt-stalk: line 419: [: -eq: unary operator expected
expr: illegal option -- -
expr: usage: expr [-e] expression

./percona-toolkit-2.2.15/bin/pt-stalk: line 419: [: -eq: unary operator expected
2015_09_08_22_42_04 Starting ./percona-toolkit-2.2.15/bin/pt-stalk --function=status --variable=Threads_running --threshold=0 --match= --cycles=5 --interval=1 --iterations= --run-time=30 --sleep=300 --dest=/var/lib/pt-stalk --prefix= --<email address hidden>,<email address hidden> --log=/var/log/pt-stalk.log --pid=/var/run/pt-stalk.pid --plugin=
2015_09_08_22_42_04 Check results: status(Threads_running)=1, matched=yes, cycles_true=1
2015_09_08_22_42_05 Check results: status(Threads_running)=1, matched=yes, cycles_true=2
2015_09_08_22_42_07 Check results: status(Threads_running)=1, matched=yes, cycles_true=3
2015_09_08_22_42_08 Check results: status(Threads_running)=1, matched=yes, cycles_true=4
^C2015_09_08_22_42_08 Caught signal, exiting
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-toolkit-2.2.15/bin/pt-stalk exit status 1

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-portbld-freebsd9.3)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

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-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

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

Revision history for this message
Sveta Smirnova (svetasmirnova) wrote :

Thank you for the report and contribution.

Verified as described.

Changed in percona-toolkit:
status: New → Confirmed
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PT-1304

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.