From 474553bedac229b967835ecd0be23a94cedb89db Mon Sep 17 00:00:00 2001 From: Ursula Date: Fri, 3 Jan 2025 22:41:33 +0200 Subject: [PATCH] fix: Fix issues with path handling in grep command Update is_contract.sh (#2359) --- scripts/is_contract.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/is_contract.sh b/scripts/is_contract.sh index 8f6a47ed6d2..8523522140f 100755 --- a/scripts/is_contract.sh +++ b/scripts/is_contract.sh @@ -34,7 +34,14 @@ SOURCE_PATH=$(cargo metadata --format-version=1 --manifest-path "$MANIFEST_PATH" | select(.id == $ROOT_PACKAGE).targets[] | select(.kind[] | contains("lib")).src_path') -if grep -q '^#\[ink::contract\([^]]*\)\]' $SOURCE_PATH; then +# Check if SOURCE_PATH is empty +if [ -z "$SOURCE_PATH" ]; then + echo "Error: Source path is empty." + exit 1 +fi + +# Check for the #[ink::contract] macro in the source file +if grep -q '^#\[ink::contract\([^]]*\)\]' "$SOURCE_PATH"; then exit 0 else exit 1