Skip to content

Commit

Permalink
fix usage of sed to support OSX and Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
markro49 committed Jun 11, 2024
1 parent a56a3f3 commit a07e3d5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions framework/core/Project/JacksonDatabind.pm
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ sub _post_checkout {
my $log = `$cmd`;
my $ret = $?;
if ($ret == 0 && length($log) > 0) {
Utils::exec_cmd("grep -lR ' extends Module\$' $work_dir | xargs sed -i 's/ extends Module\$/ extends com.fasterxml.jackson.databind.Module/'", "Correct Module ambiguity 1") or die;
Utils::exec_cmd("grep -lR ' extends Module\$' $work_dir | xargs sed -i'' -e 's/ extends Module\$/ extends com.fasterxml.jackson.databind.Module/'", "Correct Module ambiguity 1") or die;
}

$cmd = "grep -lR ' Module ' $work_dir ";
$log = `$cmd`;
$ret = $?;
if ($ret == 0 && length($log) > 0) {
Utils::exec_cmd("grep -lR ' Module ' $work_dir | xargs sed -i 's/ Module / com.fasterxml.jackson.databind.Module /'", "Correct Module ambiguity 2") or die;
Utils::exec_cmd("grep -lR ' Module ' $work_dir | xargs sed -i'' -e 's/ Module / com.fasterxml.jackson.databind.Module /'", "Correct Module ambiguity 2") or die;
}

my $project_dir = "$PROJECTS_DIR/$self->{pid}";
Expand Down
2 changes: 1 addition & 1 deletion framework/core/Project/Mockito.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ sub _post_checkout {
if ($vid == 21) {
system("rm -rf $work_dir/buildSrc/src/main/groovy/org/mockito/release/notes");
system("rm -rf $work_dir/buildSrc/src/test/groovy/org/mockito/release/notes");
system("sed -i '/apply.from:..gradle.release.gradle./d' $work_dir/build.gradle");
Utils::sed_cmd("/apply.from:..gradle.release.gradle./d", "$work_dir/build.gradle");
}

# Change Url to Gradle distribution
Expand Down
5 changes: 3 additions & 2 deletions framework/core/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,9 @@ sub sed_cmd {
print(STDERR "Executed command: sed -i $cmd_string $file_name\n") if $DEBUG;

# We ignore sed result as it is ok if command fails.
if (`uname -s` eq "Darwin" ) {
`sed -i '' $cmd_string $file_name`;
chomp(my $uname = `uname -s`);
if ($uname eq "Darwin" ) {
`sed -i '' -e '$cmd_string' $file_name`;
} else {
`sed -i "$cmd_string" "$file_name"`;
}
Expand Down

0 comments on commit a07e3d5

Please sign in to comment.