Skip to content

Commit 4ad90ba

Browse files
Copilotsofthack007
andcommitted
Fix prepare-firmware.sh - redirect debug output to stderr
Fixed error where debug output was being passed as filename to esptool.py: **Problem:** The find_file function echoed debug messages to stdout, which were then captured by command substitution and passed as arguments to esptool.py, causing "No such file or directory" errors with the debug text as the filename. **Root Cause:** In bash, command substitution $(command) captures ALL output from the command, not just the intended return value. The function was echoing both debug messages and the file path to stdout. **Fix:** - Redirect all debug output to stderr using >&2 - Only the actual file path goes to stdout - Command substitution now captures just the file path - Debug output is still visible to user but doesn't interfere with logic The script will now correctly pass file paths to esptool.py while still showing helpful debug information. Co-authored-by: softhack007 <91616163+softhack007@users.noreply.github.com>
1 parent cbd726f commit 4ad90ba

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

test/wokwi/prepare-firmware.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,24 @@ echo "Searching for required files in build directory..."
3636
echo ""
3737

3838
# Function to find file with multiple possible locations
39+
# Debug output goes to stderr, only the file path goes to stdout
3940
find_file() {
4041
local file_desc=$1
4142
shift
4243
local found_file=""
4344

44-
echo "Looking for $file_desc:"
45+
echo "Looking for $file_desc:" >&2
4546
for path in "$@"; do
46-
echo " Checking: $path"
47+
echo " Checking: $path" >&2
4748
if [ -f "$path" ]; then
4849
found_file="$path"
49-
echo " ✓ Found at: $path"
50+
echo " ✓ Found at: $path" >&2
5051
echo "$found_file"
5152
return 0
5253
fi
5354
done
5455

55-
echo " ❌ Not found in any expected location"
56+
echo " ❌ Not found in any expected location" >&2
5657
return 1
5758
}
5859

0 commit comments

Comments
 (0)