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

Do not use sh on travis because sh and bash are very different #160

Open
evandrocoan opened this issue Apr 25, 2019 · 3 comments
Open

Do not use sh on travis because sh and bash are very different #160

evandrocoan opened this issue Apr 25, 2019 · 3 comments

Comments

@evandrocoan
Copy link
Contributor

May be this is what is helping #159 (travis.sh and run_tests.py reported success when it a was failure) to exists?

UnitTesting/.travis.yml

Lines 33 to 35 in d94dcb0

- sh sbin/travis.sh bootstrap
- sh sbin/travis.sh install_color_scheme_unit
- if [ "$PCINSTALL" == true ]; then sh sbin/travis.sh install_package_control; fi

On the headers of the files, it is already defined to use #!/bin/bash, but if you directly launches it with sh travis.sh sh will be used instead of bash.

  1. https://askubuntu.com/questions/172481/is-bash-scripting-the-same-as-shell-scripting
@randy3k
Copy link
Member

randy3k commented Apr 25, 2019

AFAIK, the header is only used when the file is an executable. I don't think it is the cause of #159.

@evandrocoan
Copy link
Contributor Author

I just tested adding #!/bin/bash to all shell scripts, but the script install_sublime_text.sh crashed on Mac OS.

Currently install_sublime_text.sh has this #! /usr/bin/env bash which does nothing because it has a space after the #!. My guess, someone else was seeing this crash on Mac OS and "disabled" shell bang putting that space.

I tested it putting directly #!/bin/sh which should be the default on Mac OS and not crash happened.

@randy3k
Copy link
Member

randy3k commented Apr 25, 2019

#! /usr/bin/env bash should just work

(penguin)-~$ cat ./foo.sh
#! /usr/bin/env bash

if [[ true ]]; then
        echo TRUE
else
        echo FALSE
fi

(penguin)-~$ sh ./foo.sh
./foo.sh: 3: ./foo.sh: [[: not found
FALSE
(penguin)-~$ bash ./foo.sh
TRUE
(penguin)-~$ chmod +x ./foo.sh
(penguin)-~$ ./foo.sh
TRUE
(penguin)-~$ sh -c './foo.sh'
TRUE

The script only works in bash, and not sh (of linux) because [[ is not necessarily supported.

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

2 participants