-
Notifications
You must be signed in to change notification settings - Fork 994
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
use sh shell instead of Bash #543
Conversation
We can't change it to Bash because then the script won't work on operating
systems that don't include Bash by default.
Sent from my phone.
…On Jun 25, 2017 11:38 AM, "Bader Nasser" ***@***.***> wrote:
When installing a nightly build <https://yarnpkg.com/en/docs/nightly>
using these commands:
wget https://yarnpkg.com/install.sh
chmod +x install.sh
./install.sh --nightly
yarn installs but I get this *annoying* messages:
./install.sh: 48: ./install.sh: [[: not found
./install.sh: 53: [: unexpected operator
I know a little about shell scripting & this seems to be a bash related
thing
<https://stackoverflow.com/questions/669452/is-preferable-over-in-bash>
(and you use bash in your installation script
<https://yarnpkg.com/en/docs/install#alternatives-tab>: curl -o- -L
https://yarnpkg.com/install.sh | bash)
I'm suggesting changing sh shebang to bash shebang based on This Stack
Overflow question
<https://stackoverflow.com/questions/10376206/what-is-the-preferred-bash-shebang>
.
------------------------------
You can view, comment on, or merge this pull request online at:
#543
Commit Summary
- Change Bash shebang
File Changes
- *M* install.sh
<https://github.com/yarnpkg/website/pull/543/files#diff-0> (2)
Patch Links:
- https://github.com/yarnpkg/website/pull/543.patch
- https://github.com/yarnpkg/website/pull/543.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#543>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAFnHXpz3IT6atvxSupTgJspp8B7UBxbks5sHqlBgaJpZM4OEruR>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove any bash-isms from the script rather than forcing it to execute using Bash.
My 2 cents: We had to do the same and it's also what does nvm: https://github.com/creationix/nvm/blob/master/install.sh#L1 I would trust nvm as being a good citizen as for the shebang, has been here for a while now. |
See yarnpkg/yarn#3338 for prior discussion on a similar change in Yarn itself. |
Thanks for that detailed link |
I didn't know that bash is not available on other OSes! And I thought you are using Bash from the Should I change the script to use
And modifying the installation doc to use Edit: |
I've found that: if [ ! "$REPLY" =~ ^[Yy]$ ]; then
printf "$red> Aborting$reset\n"
exit 1
fi uses a bash syntax Edit: # if the reply doesn't start with a "y" char
if [ ! $(echo "$REPLY" | grep "^[yY]") ]; then
printf "$red> Aborting$reset\n"
exit 1
fi Or case $REPLY in [^yY]* )
printf "$red> Aborting$reset\n"
exit 1
;;
esac I prefer the The original script will abort if the $REPLY is anything not a "y" or "Y" but I think anything that doesn't start with a "y" is better (in case someone pressed more keys by mistake!) It seems like these are the only changes required to use |
Theoretically, the script now uses if echo $version | grep -qE "^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$"; then and if [ $YARN_PROFILE = *"fish"* ]; then |
Thanks for continuing to work on this 😃
This one is just
I don't think this one will work: https://github.com/koalaman/shellcheck/wiki/SC2081 |
You're welcome :) I was just worried about the regex inside grep! I still don't know how to use regexes in shell scripting & I agree it should be fine 👍 I liked the shellcheck project so I installed it & added the VSCode extension! I'm planning to implement their suggestions (I've found that my little Thanks for letting me know about this amazing tool 😃 I think it'll be nice to add it to your Travis CI script :) |
I'm almost done 😃 There're things I'm not sure about but the script is working fine :) I'll explain my changes after some break 😄 |
I tried changing printf "%s> Version number must match MAJOR.MINOR.PATCH.%s\n" "$red" "$reset Maybe my code is wrong but I couldn't achieve previous behaviour using I don't understand what's the value of Also, there's a warning about No matter what I did, @Daniel15 I think the changes are complete but maybe testing from users of |
In other PR, I've noticed that I removed my write permission from profile files using: cd ~; chmod u-w .bashrc .bash_profile .zshrc .profile and changed the if statements to use
which doesn't seem alright to me! Maybe we should change the message here and update the script to use |
It turns out that |
Hello, Are there any news about this PR? :) |
I wrote #851 before noticing this. It ended up being largely the same, but it avoids the non-portable conversion of printf "%b> Downloading tarball...%b\n" "$cyan" "$reset" and it avoids the case "$REPLY" in
Y|y)
;;
*)
printf "%b> Aborting%b\n" "$red" "$reset"
exit 1
;;
esac |
When installing a nightly build using these commands:
yarn installs but I get this annoying messages:
I know a little about shell scripting & this seems to be a bash related thing (and you use bash in your installation script:
curl -o- -L https://yarnpkg.com/install.sh | bash
)I'm suggesting changing sh shebang to bash shebang based on This Stack Overflow question.
I'm using Ubuntu 17.04.