Skip to content

Commit

Permalink
Rewrite sed commands to be less platform dependent.
Browse files Browse the repository at this point in the history
MacOS doesn't ship with version of sed that includes (convenient)
GNU extensions. We need to rewrite sed commands into a little bit more
ugly form to make them less platform dependent.
  • Loading branch information
gkossakowski committed Jan 10, 2014
1 parent c240eeb commit be6ddb3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions tests/test-sbt-incremental-play2.2-subproject.sh
Expand Up @@ -5,7 +5,9 @@
set -o nounset -o errexit

test_change1() {
sed -i '/public static Result index() {/ a \ \ \ \ \ \ \ \ ExampleLogger.log("changed");' modules/manager/app/controllers/html/StaticPages.java
sed -i '' '/public static Result index() {/ a\
ExampleLogger.log("changed");
' modules/manager/app/controllers/html/StaticPages.java
echo ""
echo "After change to controller"
git diff
Expand All @@ -26,7 +28,7 @@ test() {
local version=$1
echo "sbt.version=$version" > project/build.properties

sed -i 's/2.2.0/2.2.1/' project/plugins.sbt
sed -i '' 's/2.2.0/2.2.1/' project/plugins.sbt

echo ""
echo "********** Testing with `cat project/build.properties` **********"
Expand Down
4 changes: 3 additions & 1 deletion tests/test-sbt-incremental-securesocial.sh
Expand Up @@ -5,7 +5,9 @@
set -o nounset -o errexit

test_change() {
sed -i '/object Registration extends Controller {/ a \ \ val changed = true' app/securesocial/controllers/Registration.scala
sed -i '' '/object Registration extends Controller {/ a\
val changed = true
' app/securesocial/controllers/Registration.scala
echo ""
echo "After change to controller"
git diff
Expand Down
4 changes: 3 additions & 1 deletion tests/test-sbt-incremental-zentasks.sh
Expand Up @@ -5,7 +5,9 @@
set -o nounset -o errexit

test_change1() {
sed -i '/def index = IsAuthenticated { username => _ =>/ a \ \ val changed = true' app/controllers/Projects.scala
sed -i '' '/def index = IsAuthenticated { username => _ =>/ a\
val changed = true
' app/controllers/Projects.scala
echo ""
echo "After change to controller"
git diff
Expand Down

6 comments on commit be6ddb3

@fernandoacorreia
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for doing this. My knowledge of sed is rudimentary.

I tested your changes on Linux Mint 16 (based on Ubuntu 13.10).

Running tests/test-sbt-incremental-zentasks.sh, while in test_change1, this command:

sed -i '' '/def index = IsAuthenticated { username => _ =>/ a\
  val changed = true
' app/controllers/Projects.scala

is aborting with this error:

sed: can't read /def index = IsAuthenticated { username => _ =>/ a\
  val changed = true
: No such file or directory

@gkossakowski
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I'm not a sed expert either. The changes were driven by StackOverflow answers I found when I was running into these issues:

I'm guessing that the error you are getting is due to the fact that -i is treated differently on your system. MacOs man page says:

-i extension
         Edit files in-place, saving backups with the specified extension.  If a zero-length extension is given, no backup will be saved.  It is not recommended to give a zero-
         length extension when in-place editing files, as you risk corruption or partial content in situations where disk space is exhausted, etc.

@fernandoacorreia
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I fixed it.

Could you pull from my repository's master and test on OS X?

@gkossakowski
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested it on OS X and works like a charm! Thanks a lot!

I'll be looking into name hashing issues this week.

@fernandoacorreia
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for testing it.

@fernandoacorreia
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated my repository with these fixes.

Please sign in to comment.