Skip to content

Conversation

LaurentGoderre
Copy link
Member

If update.sh was invoked with non-existing variant, it updated all
variants. Change in_variants_to_update to return true always if
second variant argument was not given, but not when given variant
argument does not match to available variants.

@LaurentGoderre
Copy link
Member Author

This doesn't seem to work

Before this change:

./update.sh 8 alpine3.9,none

Updating version 8...
8/alpine3.9/Dockerfile is already up to date!
Done!

./update.sh 8 none

Updating version 8...
8/jessie/Dockerfile is already up to date!
8/jessie-slim/Dockerfile is already up to date!
8/stretch/Dockerfile is already up to date!
8/stretch-slim/Dockerfile is already up to date!
8/buster/Dockerfile is already up to date!
8/buster-slim/Dockerfile is already up to date!
8/onbuild/Dockerfile is already up to date!
8/alpine3.10/Dockerfile is already up to date!
8/alpine3.9/Dockerfile is already up to date!
Done!

After this change:

./update.sh 8 alpine3.9,none

Updating version 8...
8/alpine3.9/Dockerfile is already up to date!
Done!

./update.sh 8 none

./update.sh: line 96: update_variants[@]: unbound variable

If update.sh was invoked with non-existing variant, it updated all
variants.  Change in_variants_to_update to return true always if
second variant argument was not given, but not when given variant
argument does not match to available variants.
@LaurentGoderre
Copy link
Member Author

Ok, problem fixed!

@@ -97,7 +97,7 @@ function in_variants_to_update() {
local variant=$1

if [ "${#update_variants[@]}" -eq 0 ]; then
echo 0
echo 1
Copy link
Member

Choose a reason for hiding this comment

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

Echo? Not exit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah because it's a function that needs to return a boolean. This causes the script to skip the unrecognized variant

Copy link
Member

@PeterDaveHello PeterDaveHello left a comment

Choose a reason for hiding this comment

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

Maybe catch the error and give it a more clear prompt message?

@LaurentGoderre
Copy link
Member Author

Can that be done in a separate PR? Right now it breaks but with the change it will ignore it.

@PeterDaveHello
Copy link
Member

I prefer not to separate that to another PR, the change here did prevent a strange situation but also added one, line 96: update_variants[@]: unbound variable is not really understandable, and kind of exception, which IMO shouldn't be made.

@LaurentGoderre
Copy link
Member Author

How do you get that error?

@PeterDaveHello
Copy link
Member

I mean update_variants[@]: unbound variable

@LaurentGoderre
Copy link
Member Author

I used to get that error but this PR fixes this.

@PeterDaveHello
Copy link
Member

This doesn't seem to work

Before this change:

./update.sh 8 alpine3.9,none

Updating version 8...
8/alpine3.9/Dockerfile is already up to date!
Done!

./update.sh 8 none

Updating version 8...
8/jessie/Dockerfile is already up to date!
8/jessie-slim/Dockerfile is already up to date!
8/stretch/Dockerfile is already up to date!
8/stretch-slim/Dockerfile is already up to date!
8/buster/Dockerfile is already up to date!
8/buster-slim/Dockerfile is already up to date!
8/onbuild/Dockerfile is already up to date!
8/alpine3.10/Dockerfile is already up to date!
8/alpine3.9/Dockerfile is already up to date!
Done!

After this change:

./update.sh 8 alpine3.9,none

Updating version 8...
8/alpine3.9/Dockerfile is already up to date!
Done!

./update.sh 8 none

./update.sh: line 96: update_variants[@]: unbound variable

I thought update_variants[@]: unbound variable is after the change?

@LaurentGoderre
Copy link
Member Author

Aaaah,that comment was before I fixed it.

@PeterDaveHello
Copy link
Member

Oh, I misunderstood, sorry!

@PeterDaveHello PeterDaveHello merged commit e088f69 into nodejs:master Jan 9, 2020
@LaurentGoderre LaurentGoderre deleted the improve-updatesh branch January 9, 2020 14:56
@nschonni
Copy link
Member

nschonni commented Jan 10, 2020

Tried to run the update.sh for 10.18.1, but it wouldn't work till I reverted this locally
Edit: Running ./update.sh 10 on OSX with zsh (the new default shell)

@LaurentGoderre
Copy link
Member Author

@nschonni do you have more details?

@SimenB
Copy link
Member

SimenB commented Jan 10, 2020

Running ./update.sh 10 does nothing (you can revert the last commit so it's on 10.18.0 again). Running just ./update.sh does nothing either. Unsure why this change makes a difference, though...

@LaurentGoderre
Copy link
Member Author

Really?

@LaurentGoderre
Copy link
Member Author

I don't think it's necessarily this one that broke it but the one before that.

@SimenB
Copy link
Member

SimenB commented Jan 10, 2020

No, just flipping the 1 back to 0 fixes it. You can test on master.

$ ./update.sh
Updating version 10...
Updating version 12...
Updating version 13...
Updating version chakracore/10...
chakracore/10/Dockerfile is already up to date!
Done!
$ git revert --no-edit 6c3fa2f322cbff89885a849a7dfe69972ce97a30
Auto-merging update.sh
[master e961171] Revert "Fix update.sh invocation with unknown variant"
 Date: Fri Jan 10 15:37:30 2020 +0100
 1 file changed, 1 insertion(+), 1 deletion(-)
$ git diff origin/master
diff --git c/update.sh w/update.sh
index 25d61dc..87f1c86 100755
--- c/update.sh
+++ w/update.sh
@@ -97,7 +97,7 @@ function in_variants_to_update() {
   local variant=$1
 
   if [ "${#update_variants[@]}" -eq 0 ]; then
-    echo 1
+    echo 0
     return
   fi

$ ./update.sh
Updating version 10...
Updating version 12...
Updating version 13...
10/jessie/Dockerfile is already up to date!
10/jessie-slim/Dockerfile is already up to date!
10/stretch/Dockerfile is already up to date!
10/buster/Dockerfile is already up to date!
10/buster-slim/Dockerfile is already up to date!
12/stretch/Dockerfile is already up to date!
12/buster/Dockerfile is already up to date!
10/stretch-slim/Dockerfile is already up to date!
12/buster-slim/Dockerfile is already up to date!
Updating version chakracore/10...
12/stretch-slim/Dockerfile is already up to date!
13/buster/Dockerfile is already up to date!
13/stretch/Dockerfile is already up to date!
13/stretch-slim/Dockerfile is already up to date!
13/buster-slim/Dockerfile is already up to date!
10/alpine3.10/Dockerfile is already up to date!
10/alpine3.11/Dockerfile is already up to date!
10/alpine3.9/Dockerfile is already up to date!
chakracore/10/Dockerfile is already up to date!
12/alpine3.9/Dockerfile is already up to date!
12/alpine3.11/Dockerfile is already up to date!
12/alpine3.10/Dockerfile is already up to date!
13/alpine3.10/Dockerfile is already up to date!
13/alpine3.11/Dockerfile is already up to date!
Done!

@LaurentGoderre
Copy link
Member Author

You're right. #1192

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants