Description
The rename_app.sh script uses macOS/BSD sed syntax (sed -i ''), which causes it to fail on Linux systems that use GNU sed. When attempting to run the script on Linux, all sed commands fail with "No such file or directory" errors.
Environment
- OS: Linux (Arch Linux, kernel 6.17.3-arch2-1-lily)
- Shell: bash
- sed: GNU sed
Steps to Reproduce
- Clone the repository on a Linux system
- Run the rename script:
./rename_app.sh --app-name "something" --package-name "io.github.something"
- Confirm with y when prompted
Expected Behavior
The script should successfully rename the app and update package names across all platform files.
Actual Behavior
All sed commands fail with errors like:
sed: cannot read s/.*</string>/substurgeon</string>/g: No such file or directory
Root Cause
The script uses BSD sed syntax (sed -i '') which is specific to macOS. On Linux, GNU sed expects:
- BSD sed (macOS): sed -i '' 's/pattern/replacement/g' file
- GNU sed (Linux): sed -i 's/pattern/replacement/g' file
When GNU sed encounters sed -i '', it interprets '' as a filename argument instead of an empty backup extension, causing the "No such file or directory" error.
Suggested Fix
Make the script cross-platform compatible by detecting the OS and using the appropriate sed syntax:
# Detect OS and set appropriate sed command
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS/BSD
alias sed_i='sed -i ""'
else
# Linux/GNU
alias sed_i='sed -i'
fi
Or replace all occurrences of sed -i '' with sed -i (Linux-compatible) as a temporary fix for Linux users.
Additional Context
This is a common portability issue between macOS and Linux scripts. Using the OSTYPE variable to detect the platform allows the script to work on both systems seamlessly.
Description
The rename_app.sh script uses macOS/BSD sed syntax (sed -i ''), which causes it to fail on Linux systems that use GNU sed. When attempting to run the script on Linux, all sed commands fail with "No such file or directory" errors.
Environment
Steps to Reproduce
./rename_app.sh --app-name "something" --package-name "io.github.something"
Expected Behavior
The script should successfully rename the app and update package names across all platform files.
Actual Behavior
All sed commands fail with errors like:
sed: cannot read s/.*</string>/substurgeon</string>/g: No such file or directory
Root Cause
The script uses BSD sed syntax (sed -i '') which is specific to macOS. On Linux, GNU sed expects:
When GNU sed encounters sed -i '', it interprets '' as a filename argument instead of an empty backup extension, causing the "No such file or directory" error.
Suggested Fix
Make the script cross-platform compatible by detecting the OS and using the appropriate sed syntax:
Or replace all occurrences of
sed -i ''withsed -i(Linux-compatible) as a temporary fix for Linux users.Additional Context
This is a common portability issue between macOS and Linux scripts. Using the
OSTYPEvariable to detect the platform allows the script to work on both systems seamlessly.