rust-lang / rust-installer

The Bourne shell installer used by Rust and Cargo
Apache License 2.0
60 stars 68 forks source link

/bin/sh and sh may not be a Bourne-like shell #2

Open postmodern opened 9 years ago

postmodern commented 9 years ago

It's not clear whether the rust-installer is targeting all POSIX shells or just Bourne shells. /bin/sh is not guaranteed to point to a Bourne-like shell. For example on Ubuntu, /bin/sh is symlinked to /bin/dash, or the Debian Almquist Shell.

brson commented 9 years ago

Do you have a suggestion?

postmodern commented 9 years ago

Using #!/bin/bash or #!/usr/bin/env bash and targeting Bash >= 3 seems to be the safest. Most Linux distros have upgraded to Bash 4, while OSX still ships Bash 3.

brson commented 9 years ago

@postmodern I'm interested in targeting bourne shell specifically.

postmodern commented 9 years ago

I would then add checks for non-Bourne shells.

brson commented 9 years ago

@postmodern Do you have pointers about how to do those checks? I'm not familiar.

Sorry it's taken me so long to circle back around to rust-installer. I've been on other things for a while, but starting a big upgrade now.

postmodern commented 9 years ago

I normally explicitly check for $BASH_VERSION or $ZSH_VERSION. Not sure how you'd check whether a shell is bourne compatible.