@@ -12,6 +12,15 @@ TAG=""
1212TAP=" redis/redis"
1313ACTION=" "
1414
15+ # Detect OS for sed compatibility
16+ if [[ " $OSTYPE " == " darwin" * ]]; then
17+ # macOS requires empty string for in-place editing
18+ SED_INPLACE=" sed -i ''"
19+ else
20+ # Linux doesn't need the empty string
21+ SED_INPLACE=" sed -i"
22+ fi
23+
1524# Function to display usage
1625usage () {
1726 echo " Usage: $0 --cask <cask_name> --action <action> [--binary <binary_path>] [--package-json <json>] [--tap <tap_name>] <TAG>"
@@ -53,9 +62,9 @@ edit_cask_file(){
5362 fi
5463
5564 # Change url to file://
56- sed -i ' ' " s|url \" .*\" |url \" file://$binary_path \" |" $casks_path
65+ $SED_INPLACE " s|url \" .*\" |url \" file://$binary_path \" |" $casks_path
5766 # Remove sha256 verification since it's testing
58- sed -i ' ' ' /sha256 arm:/,/intel:.*"$/d' $casks_path
67+ $SED_INPLACE ' /sha256 arm:/,/intel:.*"$/d' $casks_path
5968
6069 elif [ " $action " = " publish" ]; then
6170 casks_path=" $( pwd) /Casks/${cask_name} .rb"
@@ -75,8 +84,8 @@ edit_cask_file(){
7584 # Update sha256 values in cask file
7685 if [ -n " $arm_sha " ] && [ -n " $intel_sha " ]; then
7786 # Replace existing sha256 line with new values
78- sed -i " s/sha256 arm: \" [^\" ]*\" ,$/sha256 arm: \" $arm_sha \" ,/" $casks_path
79- sed -i " /sha256 arm:/,/intel:/ s/intel: \" [^\" ]*\" /intel: \" $intel_sha \" /" " $casks_path "
87+ $SED_INPLACE " s/sha256 arm: \" [^\" ]*\" ,$/sha256 arm: \" $arm_sha \" ,/" $casks_path
88+ $SED_INPLACE " /sha256 arm:/,/intel:/ s/intel: \" [^\" ]*\" /intel: \" $intel_sha \" /" " $casks_path "
8089 else
8190 echo " Error: Missing sha256 values in package_json"
8291 exit 1
@@ -88,7 +97,7 @@ edit_cask_file(){
8897 fi
8998
9099 # Change version
91- sed -i " s/version \" [^\" ]*\" /version \" $tag \" /" $casks_path
100+ $SED_INPLACE " s/version \" [^\" ]*\" /version \" $tag \" /" $casks_path
92101}
93102
94103# Parse command line arguments
0 commit comments