Fix script_phases.sh error() helper: missing echo + arg truncation (fixes #56955)#56959
Open
LeSingh1 wants to merge 1 commit into
Open
Fix script_phases.sh error() helper: missing echo + arg truncation (fixes #56955)#56959LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
…acebook#56955) The error() helper had two bugs since its extraction from the Ruby script in commit 1dbbeb4: 1. The line that mirrors the formatted message to SCRIPT_OUTPUT_FILE_0 was missing the leading echo, so [Codegen] $1 was instead being executed as a command. Under set -e this aborts the script with status 127 before reaching exit 1, and SCRIPT_OUTPUT_FILE_0 receives a shell command not found error instead of the intended log line. 2. The function only printed $1, so multi-arg callers like find_node (which passes its message across three space-and-backslash continuation strings) were silently truncated to the first chunk. Switch both lines to use $* so all positional arguments are joined into a single space-separated message, and add the missing echo so the second line actually appends to the log file. Fixes facebook#56955.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #56955.
Bug
packages/react-native/scripts/react_native_pods_utils/script_phases.shdefines:This has two problems that have been present since the script was extracted from
react_native_pods.rbin commit 1dbbeb4 (Move script_phases script out of ruby file):echoon the log line. The second line does not actually write to the file — it tries to execute the formatted string as a command. Underset -e(which this script enables on line 8) this aborts with status 127 before reachingexit 1, andSCRIPT_OUTPUT_FILE_0ends up containing a shellcommand not founderror instead of the intended[Codegen] ...log line.$1are silently dropped.find_nodecallserrorwith three space-and-backslash continuation strings (lines 27-29). Each is a separate positional arg. The helper only prints$1, so chunks 2 and 3 are lost from both the visible message and the log file.Repro (standalone shell, no react-native checkout needed)
Fix
Switch both lines to
$*so all positional arguments are joined into a single space-separated message, and add the missingechoso the second line actually appends to the log file:After the fix:
error hello→ printshello, log contains[Codegen] helloerror "[Error] line 1" "line 2" "line 3"→ prints[Error] line 1 line 2 line 3, log contains[Codegen] [Error] line 1 line 2 line 3set -eno longer aborts mid-helper;exit 1runs as intendedTest plan
Single-file change in a Pods build-phase helper script. The fix preserves the original message-to-stderr behavior and adds the missing message-to-log-file behavior plus correct multi-arg handling.
Verified the broken behavior with the shell repro above against current
main(b32a6c9e9db). The same repro succeeds after the fix.Changelog:
[iOS] [Fixed] - Fix
error()helper inscript_phases.shthat swallowed multi-arg messages and crashed with status 127 underset -edue to a missingecho