Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible condition - task10 #25

Closed
ghost opened this issue Apr 27, 2022 · 5 comments
Closed

Impossible condition - task10 #25

ghost opened this issue Apr 27, 2022 · 5 comments

Comments

@ghost
Copy link

ghost commented Apr 27, 2022

Hi, guys!

Amazing lab, thank you!

I have question about task 10, file Jenkinsfile, line 14. This condition ought to be true to merge my pull request in the main branch. But this condition can't be true because $(wc -l <version) always return 1 (1 string in the file) and it's can't be equal to 0.

Thank you in advance.

@omer-cider
Copy link
Contributor

Hi @v3nd1g0, welcome and great to see you like to lab!
This shouldn't be a mistake, and it works for me. Have you tried running this command on this file and see what it returns?
Also, have you tried following the hints or solution and see if it works for you?

@ghost
Copy link
Author

ghost commented Apr 27, 2022

Hi @omer-cider. Thank you for your reply.
I have tested this expression in zshrc in such conditions:

  • empty version file
$ > ./version
$ if [ $(wc -l <version) -eq 0 -a $(grep -Po "^\\d{1,2}\\.\\d{1,2}\\.\\d{1,2}$" version) ] ; then check2=true; else check2=false; fi && echo $check2
false
  • version file with 1.0.13 (grep pattern ok)
$ echo "1.0.13" > ./version 
$ if [ $(wc -l <version) -eq 0 -a $(grep -Po "^\\d{1,2}\\.\\d{1,2}\\.\\d{1,2}$" version) ] ; then check2=true; else check2=false; fi && echo $check2
false
  • version file with 100.1000.1000 (grep pattern no ok)
$ echo "1.100.100" > ./version 
$ if [ $(wc -l <version) -eq 0 -a $(grep -Po "^\\d{1,2}\\.\\d{1,2}\\.\\d{1,2}$" version) ] ; then check2=true; else check2=false; fi && echo $check2
false

In each case I have reached check2 == false.

What am I missing?
Thank you in advance.

P.S. I have checked writeup, but it doesn't work for me :c

@omer-cider
Copy link
Contributor

omer-cider commented May 9, 2022

Hi @v3nd1g0, wc -l <version counts the number of newlines. If you'll make sure to remove any \ns from the version file, the command will return true.

@ghost
Copy link
Author

ghost commented May 10, 2022

Thank you, you are right!

@ghost ghost closed this as completed May 10, 2022
@omer-cider
Copy link
Contributor

Awesome, have fun!

This issue was closed.
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

No branches or pull requests

1 participant