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

Convert all sh scripts to bash scripts #31036

Closed
brson opened this issue Jan 20, 2016 · 19 comments
Closed

Convert all sh scripts to bash scripts #31036

brson opened this issue Jan 20, 2016 · 19 comments
Assignees
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Comments

@brson
Copy link
Contributor

brson commented Jan 20, 2016

We've long stuck to posix shell for our bash scripts with the rationale that posix shell is the most compatible. Sometimes this has been painful. Most recently, IllumOS doesn't have a working posix shell, but it does have bash. Conversely, I have no real-world examples of platforms people are using Rust on that only have sh.

I'm near the breaking point of my sympathy for sh now.

This must be done in-tree, as well as in rustup.sh and rust-installer.

This issue has been assigned to @Daniel-Worrall via this comment.

@brson
Copy link
Contributor Author

brson commented Jan 20, 2016

cc @steveklabnik

@brson
Copy link
Contributor Author

brson commented Jan 20, 2016

cc @rust-lang/tools

@brson
Copy link
Contributor Author

brson commented Jan 20, 2016

The obvious place I can imagine this matter is installing rustc on busybox platforms, perhaps Android based.

@wycats
Copy link
Contributor

wycats commented Jan 20, 2016

For what it's worth, I've been playing with getting rust installed on non-standard platforms like aboriginal Linux and unrooted android recently and I can confirm that this is one of the biggest issues.

That said, the script itself is not perfectly compatible with busybox bash, which would be good to fix :)

@steveklabnik
Copy link
Member

I'm fine with this 👍

@alexcrichton
Copy link
Member

I was poking around in FreeBSD and OpenBSD recently and it looks like neither have bash installed by default, but both have bash packages (just a point of note)

@brson
Copy link
Contributor Author

brson commented Jan 20, 2016

@wycats That sounds like a vote for sticking with sh and fixing busybox compatibility?

@wycats
Copy link
Contributor

wycats commented Jan 20, 2016

@brson I think so yes.

@nodakai
Copy link
Contributor

nodakai commented Jan 23, 2016

I wonder if we can do something like /non/standard/path/sh configure.sh so that users can choose whichever installation they prefer.

@raphaelcohn
Copy link

raphaelcohn commented May 8, 2016

Just found this thread and I've got a quick observation on sh on BusyBox (I'm the main developer of shellfire).

There's two variants of sh on BusyBox: an ash (Almquist) derived one, and hush. hush is a bit... weird, but is used by some folks because, IIRC, it works on MMU-less systems, and BusyBox's ash doesn't. In addition, BusyBox's ash has a few small patches to accept a few small bashisms. In practice, apart from useful changes to read for scripts using socat, etc, you shouldn't need to rely on any. It's also worth pointing out that ksh is POSIX compliant in its ksh88 form, but isn't in ksh93 form, and its idea of local is at odds with all other shells... it's a completely different feature.

I, and a number of others in the devops space are moving off bash because of its code smells, bug history and brittleness. There have been just too many problems over the years. And it's not commonly installed on non-Linux setups, etc.

I'd strongly suggest writing scripts and testing with pdksh. If they work with that, they'll work with mksh, dash, bash (running as sh, which is actually uncommon now, as it's often weird), ksh88, OpenBSD's variants, etc. I don't have much availability at the moment (legal shenanigans) but I'm happy to try to help out over email with script issues if you can get me access to a system. Shell script debugging is ...

@Mark-Simulacrum
Copy link
Member

@brson Do we want to go with the pdksh approach suggested above? That seems to be the best option based on discussion above.

@Mark-Simulacrum
Copy link
Member

Nominating for infra team so we can come to a decision on this.

@Mark-Simulacrum Mark-Simulacrum added T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. I-nominated labels Jun 22, 2017
@Mark-Simulacrum
Copy link
Member

Discussed in meeting: We want to survey the current state of the world to know what's still written in shell, and come to decisions based on what it is how much of it needs to be in shell. Marking as help wanted, if you want to look across rust-lang/cargo, rust-lang/rust-installer, rust-lang/rust and find shell scripts and note them here, please do so. cc @alexcrichton -- feel free to edit with additional repos.

@nodakai
Copy link
Contributor

nodakai commented Jun 24, 2017

@Mark-Simulacrum rust-installer is a serious shell script project which is not only written in shell but also generates a shell script. But I don't know if it will remain in a high demand, especially after rust-lang/rustup#313 is resolved.

@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 24, 2017
@kzys
Copy link
Contributor

kzys commented Oct 10, 2018

There are 48 shell scripts, but most of them are under src/ci/docker.

% git grep '#!/.*sh'
configure:1:#!/bin/sh
src/ci/docker/disabled/dist-x86_64-dragonfly/build-toolchain.sh:1:#!/usr/bin/env bash
src/ci/docker/disabled/dist-x86_64-haiku/build-toolchain.sh:1:#!/usr/bin/env bash
src/ci/docker/disabled/dist-x86_64-haiku/fetch-packages.sh:1:#!/usr/bin/env bash
src/ci/docker/disabled/dist-x86_64-haiku/llvm-config.sh:1:#!/bin/sh
src/ci/docker/disabled/wasm32-exp/node.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-aarch64-linux/build-toolchains.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-arm-linux/build-toolchains.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-armhf-linux/build-toolchains.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-armv7-linux/build-toolchains.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-powerpc-linux/build-powerpc-toolchain.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-powerpc64-linux/build-powerpc64-toolchain.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-s390x-linux/build-s390x-toolchain.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-various-1/build-rumprun.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-various-1/install-x86_64-redox.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-various-2/build-cloudabi-toolchain.sh:1:#!/bin/bash
src/ci/docker/dist-various-2/build-fuchsia-toolchain.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-various-2/build-fuchsia-toolchain.sh:59:#!/bin/sh
src/ci/docker/dist-various-2/build-solaris-toolchain.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-x86_64-linux/build-binutils.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-x86_64-linux/build-clang.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-x86_64-linux/build-cmake.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-x86_64-linux/build-curl.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-x86_64-linux/build-gcc.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-x86_64-linux/build-git.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-x86_64-linux/build-headers.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-x86_64-linux/build-openssl.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-x86_64-linux/build-python.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh:1:#!/usr/bin/env bash
src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh:67:#!/usr/bin/env bash
src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh:72:#!/usr/bin/env bash
src/ci/docker/run.sh:1:#!/usr/bin/env bash
src/ci/docker/scripts/android-start-emulator.sh:1:#!/bin/sh
src/ci/docker/scripts/freebsd-toolchain.sh:1:#!/bin/bash
src/ci/docker/scripts/freebsd-toolchain.sh:99:#!/bin/sh
src/ci/docker/scripts/qemu-bare-bones-rcS:1:#!/bin/sh
src/ci/docker/x86_64-gnu-tools/checktools.sh:1:#!/bin/sh
src/ci/docker/x86_64-gnu-tools/repo.sh:1:#!/bin/sh
src/ci/init_repo.sh:1:#!/usr/bin/env bash
src/ci/run.sh:1:#!/usr/bin/env bash
src/etc/cat-and-grep.sh:1:#!/bin/sh
src/etc/installer/pkg/postinstall:1:#!/bin/sh
src/etc/rust-gdb:1:#!/bin/sh
src/etc/rust-gdbgui:1:#!/bin/sh
src/etc/rust-lldb:1:#!/bin/sh
src/test/run-make/git_clone_sha1.sh:1:#!/bin/bash -x
src/tools/build-manifest/README.md:13:#!/bin/bash
% git grep '#!/.*sh' | wc -l
      48
%

@jonas-schievink jonas-schievink added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) and removed T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) A-build labels Apr 21, 2019
@Daniel-Worrall
Copy link
Contributor

@rustbot claim

@JohnTitor
Copy link
Member

Triage: There's no active interest since #71932 was closed. Could we close this issue for now?

@raphaelcohn
Copy link

@JohnTitor Yes please!

@JohnTitor
Copy link
Member

Okay, I'm going to close this but feel free to re-open if someone has an interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests