Skip to content

Commit 5b61b2d

Browse files
authored
chore: Accumulated backports to v4-next (#23386)
BEGIN_COMMIT_OVERRIDE fix(aztec-up): fall back to no timeout when /usr/bin/timeout absent (macOS) (#23310) fix(aztec): use perl -i for portable in-place edit in add_crate.sh (#23335) END_COMMIT_OVERRIDE
2 parents 1a40b92 + 38ae87a commit 5b61b2d

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

aztec-up/bin/0.0.1/install

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,21 @@ function echo_yellow {
5555
}
5656

5757
function timeout {
58-
if [ "${CI:-0}" = "1" ] || [ "${CI:-0}" = "true" ]; then
58+
if [ "${CI:-0}" != "1" ] && [ "${CI:-0}" != "true" ]; then
59+
shift
60+
"$@"
61+
return
62+
fi
63+
if [ -x /usr/bin/timeout ]; then
64+
# Prefer coreutils `timeout` when available. Absolute path avoids re-entering this function.
5965
/usr/bin/timeout "$@"
66+
elif perl -e1 2>/dev/null; then
67+
# Fall back to perl's `alarm` when /usr/bin/timeout is missing.
68+
local duration=$1
69+
shift
70+
perl -e "alarm $duration; exec @ARGV" -- "$@"
6071
else
72+
# No timeout backend available -- run unguarded rather than fail the install.
6173
shift
6274
"$@"
6375
fi

yarn-project/aztec/scripts/add_crate.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,17 @@ TEMPLATE_DIR="$(dirname $0)/templates/$template"
3737
# Copy template crates and substitute placeholders
3838
cp -r "$TEMPLATE_DIR/contract" "$contract_dir"
3939
cp -r "$TEMPLATE_DIR/test" "$test_dir"
40+
# Use perl -i for portability across os.
4041
find "$contract_dir" "$test_dir" -type f -exec \
41-
sed -i -e "s/__CRATE_NAME__/${crate_name}/g" -e "s/__AZTEC_VERSION__/${AZTEC_VERSION}/g" {} +
42+
perl -i -pe "s/__CRATE_NAME__/${crate_name}/g; s/__AZTEC_VERSION__/${AZTEC_VERSION}/g" {} +
4243

4344
# Add members to workspace Nargo.toml
4445
if grep -q 'members\s*=\s*\[\s*\]' Nargo.toml; then
4546
# Empty array: members = []
46-
sed -i "s|members\s*=\s*\[\s*\]|members = [\"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
47+
perl -i -pe "s|members\s*=\s*\[\s*\]|members = [\"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
4748
else
4849
# Non-empty array: add before closing ]
49-
sed -i "s|\(members\s*=\s*\[.*\)\]|\1, \"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
50+
perl -i -pe "s|(members\s*=\s*\[.*)\]|\1, \"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
5051
fi
5152

5253
echo "Created crates '${contract_dir}' and '${test_dir}'"

0 commit comments

Comments
 (0)