You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This tries to determine the version of the btp executable (in $file) by parsing the output from the --version option. Here's what that looks like (i.e. when btp --version is invoked):
SAP BTP command line interface (client v2.8.0)
OK
The empty line and the "OK" are actually emitted to STDOUT so we throw them away by redirecting STDOUT to nowhere (2> /dev/null).
Then we have the single line to parse a version number from. We're looking for the form "x.y.z" which in this example would be "2.8.0". In order to identify such a version number as "accurately" as possible, the regular expression is being employed:
(?<=v)\d+\.\d+\.\d+
This uses a lookbehind assertion(?<=v) which says what is to be matched (\d+\.\d+\.\d+) must directly follow a lower case v; the assertion is there because the v needs to be there but not included in what's matched. Such assertions are part of the Perl Compatible Regular Expressions family, which are not available with the stock macOS version of grep (identified at the time of writing as "2.5.1-FreeBSD"). They are available with the more widespread GNU version of grep, via the -P option, which is used here.
I'd recommend you install the GNU version of grep as it's more powerful and arguably more widespread. You can do this simply by using Homebrew, and then adding the path to the newly installed executable, so that it comes before the location of the stock macOS grep. In other words:
For those wondering, the -o option tells grep to just return the actual string that matched (i.e. just the "x.y.z" version number), rather than the default which would be the entire line that it found with such a match.
Finally, not that it helps much, but there's actually a note in the script, in this get_version function, that says we're using the GNU version:
# Determine the version (uses the proper grep, from GNU)
This issue relates to the content in the 2021-09-01-btp-cli-installation branch of this repo.
Running the
getbtpcli
script on a standard macOS device results in an error relating togrep
:This issue was encountered and logged in this comment to the blog post SAP Tech Bytes: btp CLI – installation that accompanies this repo branch.
The text was updated successfully, but these errors were encountered: