Skip to content

Commit

Permalink
updated rewrite trinket script
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Sep 6, 2024
1 parent 2a9b19c commit 9a784db
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions rewrite_trinket_source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,35 @@ fi
CURRENT_LINE=$(sed -n '258p' "$FILE_PATH")

if [ "$CURRENT_LINE" != " delay(10);" ]; then
echo "No changes made: line 258 does not match the expected content or has already been modified."
exit 0
if [ "$CURRENT_LINE" != " \/\/delay(10);" ]; then
echo "No changes made: line 258 does not match the expected content."
exit 1
fi
echo "No changes made: line 258 has already been modified."
else
# Replace the content of line 258
sed -i '258s/.*/ \/\/delay(10);/' "$FILE_PATH"
echo "Line 258, a delay(10), has been commented out in: [$FILE_PATH]"
fi

# Replace the content of line 258
sed -i '258s/.*/ \/\/delay(10);/' "$FILE_PATH"
# =============================================================================================

echo "Line 258, a delay(10), has been commented out in: [$FILE_PATH]"
FILE_PATH2="$HOME/.arduino15/packages/adafruit/hardware/samd/1.7.16/cores/arduino/USB/USBAPI.h"
# Check if the file exists
if [ ! -f "$FILE_PATH2" ]; then
echo "Error: File does not exist."
exit 1
fi
# Read the specific line and check its content
CURRENT_LINE=$(sed -n '182p' "$FILE_PATH2")
if [ "$CURRENT_LINE" != "private:" ]; then
if [ "$CURRENT_LINE" != "\/\/private:" ]; then
echo "No changes made: line 182 does not match the expected content."
exit 1
fi
echo "No changes made: line 182 has already been modified."
else
# replace the content of line
sed -i '182s/.*/\/\/private:/' "$FILE_PATH2"
echo "Line 182, private: has been commented out in: [$FILE_PATH2]"
fi

0 comments on commit 9a784db

Please sign in to comment.