sweetbbak / go-moreutils

coreutils with some more modern features. Written in go. Thanks to u-root, the golang unix lib and gnu coreutils for showing me what to do. These may be handy to use but 100% parity is not guaranteed or aimed for, just use toyobx/busybox at that point.
12 stars 0 forks source link

[Bugfix?] Get rid of Bash as a dependency. (So that it can work on Alpine & other lightweight environments) #3

Open xplshn opened 5 months ago

xplshn commented 5 months ago

cmd/unshare: Hardcodes bash, when it should resort to SH, which is what POSIX compliant systems use (Also those that aren't POSIX compliant tend to just link their default shell to /bin/sh)

func getShell() string {
    sh := os.ExpandEnv("SHELL")
    if sh == "" {
        sh = "/bin/bash"
    }
    return sh
}

cmd/sshd also, add the "ash" and "hush" shell to the list, along with "yash" & "ksh", given that ksh is common place on *BSD systems, and I use that too. In line 46 you should update this, in order for it to work on systems that use other shells:

var shells = []string{"sh", "bash", "zsh", "dash", "fish", "elvish"}

Also, https://github.com/search?q=repo%3Asweetbbak%2Fgo-moreutils%20bash&type=code There are tons of scripts which could just /bin/sh instead of /bin/env/bash so that they run on more systems.

sweetbbak commented 5 months ago

Thanks, I'll add those to the list, and you're right it should be sh by default unless the user specifies otherwise.

xplshn commented 5 months ago

Thanks! Cool project, I very much like being able to pass colors to echo, no matter how much I hate nonPOSIX things its convenient for scripts that'll only run on my PC. Very cool indeed.