fairDataSociety / fdp-contracts

Fair Data Protocol smart contracts and its utilities
4 stars 1 forks source link

Use cross-platform parsing #48

Open IgorShadurin opened 2 years ago

IgorShadurin commented 2 years ago

https://github.com/fairDataSociety/fdp-contracts/blob/1909737246399bd7546a116856db03f34a55ace6/scripts/build-image.sh#L26

this command throw an error on mac os

grep: invalid option -- P
usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
    [-e pattern] [-f file] [--binary-files=value] [--color=when]
    [--context[=num]] [--directories=action] [--label] [--line-buffered]
    [--null] [pattern] [file ...]

Info from stackoverflow

grep -P enables PCRE syntax. (This is a non-standard extension -- not even all builds of GNU grep support it, as it depends on the optional libpcre library, and whether to link this in is a compile-time option).

It would be great to replace it with some params that supported on mac os.

crtahlin commented 1 year ago

Please triage for urgency @nugaon .

crtahlin commented 1 year ago

Please add your planning poker estimate with ZenHub @nugaon

nugaon commented 1 year ago

it is not that urgent as this should be built by the github ci which uses Linux.

since I don't have mac to try out the mac solution, maybe @IgorShadurin could address this issue and find the solution that works on OSX as well.

IgorShadurin commented 1 year ago

To extract the contract address from the DEPLOYMENT_OUTPUT variable on Mac and Ubuntu, use the awk command. This solution uses awk to match lines with the FDSRegistrar deployed to: string and prints the fourth field, which should be the contract address. Here's an example:

FDS_REGISTRAR_ADDRESS=$(echo $DEPLOYMENT_OUTPUT | awk '/FDSRegistrar deployed to:/ {print $4}')

But it should be tester with real data