mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-07 21:09:14 +00:00
Fix a section() bug.
Turns out that awk's indexes are documented to start from 1; So what happens if you use 0? Apparently it's undefined behavior, so substr(var, 0, 5); and substr(var, 1, 5); May or may not actually do the same thing. In Debian 6, the former doesn't quite work, and actually returns something like substr(var, 1, 4), which broke section()'s output.
This commit is contained in:
@@ -560,7 +560,7 @@ section () {
|
||||
i = index($0, "_");
|
||||
x = substr($0, i);
|
||||
gsub(/[_ \t]/, "#", x);
|
||||
printf("%s%s\n", substr($0, 0, i-1), x);
|
||||
printf("%s%s\n", substr($0, 1, i-1), x);
|
||||
}')"
|
||||
printf "%s\n" "${line}"
|
||||
}
|
||||
|
@@ -697,7 +697,7 @@ section () {
|
||||
i = index($0, "_");
|
||||
x = substr($0, i);
|
||||
gsub(/[_ \t]/, "#", x);
|
||||
printf("%s%s\n", substr($0, 0, i-1), x);
|
||||
printf("%s%s\n", substr($0, 1, i-1), x);
|
||||
}')"
|
||||
printf "%s\n" "${line}"
|
||||
}
|
||||
|
Reference in New Issue
Block a user