Skip to content

Commit a717133

Browse files
Copilotrolfbjarne
andcommitted
Fix sed syntax for Linux in create-makefile-fragment.sh
Co-authored-by: rolfbjarne <249268+rolfbjarne@users.noreply.github.com>
1 parent a21bcfb commit a717133

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tools/common/create-makefile-fragment.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515

1616
cd "$(dirname "$0")"
1717

18+
# Detect OS for sed syntax
19+
if [[ "$OSTYPE" == "darwin"* ]]; then
20+
SED_INPLACE="sed -i ''"
21+
else
22+
SED_INPLACE="sed -i"
23+
fi
24+
1825
if test -z "$1"; then
1926
echo "Must specify the project file to process."
2027
exit 1
@@ -104,12 +111,12 @@ for proj in $(sort "$REFERENCES_PATH" | uniq); do
104111

105112
# The output contains relative paths, relative to the csproj directory
106113
# Change those to full paths by prepending the csproj directory.
107-
sed -i '' "s@^@$proj_dir/@" "$inputs_path"
114+
$SED_INPLACE "s@^@$proj_dir/@" "$inputs_path"
108115

109116
# Change to Make syntax. This is horrifically difficult in MSBuild,
110117
# because MSBuild blindly replaces backslashes with forward slashes (i.e.
111118
# windows paths to unix paths...)
112-
sed -i '' "s_^\\(.*\\)\$_ \\1 \\\\_" "$inputs_path"
119+
$SED_INPLACE "s_^\\(.*\\)\$_ \\1 \\\\_" "$inputs_path"
113120

114121
# Clean up
115122
rm -f "$TMPPROJ"
@@ -125,7 +132,7 @@ sort "${INPUT_PATHS[@]}" | uniq >> "$FRAGMENT_PATH"
125132

126133
# Simplify paths somewhat by removing the current directory
127134
if test -z "$ABSOLUTE_PATHS"; then
128-
sed -i '' "s@$PROJECT_DIR/@@" "$FRAGMENT_PATH"
135+
$SED_INPLACE "s@$PROJECT_DIR/@@" "$FRAGMENT_PATH"
129136
fi
130137

131138
# Cleanup

0 commit comments

Comments
 (0)