mimi
mimi copied to clipboard
`$SHELL` should be changed to `sh` or `bash`
I have nushell as my user shell, thus the following doesn't work:
run() {
$SHELL -c "'$1' $(printf "%q " "${@:2}")"
}
I suggest to change $SHELL to sh (if that's safe) or bash.
I could add SHELL to the environmental variables parsed from the config, e.g. something like
CONFIG_SHELL=$(find_in_config SHELL)
if exists "$CONFIG_SHELL"; then
SHELL=$CONFIG_SHELL
fi
and then in the config you could write
SHELL: bash
What do you think?
Sure, that would work. However, i don't understand the reasoning behind using $SHELL in the first place:
With mimi being a bash script, why not hardcode bash or set bash as the default unless something else is specified? Do you want to pull in environment variables from $SHELL that are not set globally?
@Schweber You're right, might as well hardcore it.
Use a simple nop assignation: if $SHELL is not set, shell is $0
@Schweber You're right, might as well hardcore it.
sh is the only bin available in $PATH on nix/os, we have to patch anything else usually.
@Schweber You're right, might as well hardcore it.
shis the only bin available in $PATH on nix/os, we have to patch anything else usually.
Sounds like an issue with Nix. Usually projects don't adapt for the one and single exception...
There was not a counterargument provided for making it bash by default, so I think it was worth adding for fairness. It is not an issue, as much as it is worth noting that bash itself could be considered an opinionated choice under a certain thought process.
It is not an issue, as much as it is worth noting that bash itself could be considered an opinionated choice under a certain thought process.
As much as I might agree with that, the script itself is far from being POSIX-compliant, so I'm definitely not going to make it #!/bin/sh for the time being.
Also, I'm not at all an expert with nix but I imagine it is standard to patch bash scripts when packaging, see e.g. https://ertt.ca/nix/shell-scripts/#orgcdf8a6f
As much as I might agree with that, the script itself is far from being POSIX-compliant, so I'm definitely not going to make it
#!/bin/shfor the time being.
That's fine. The present value of #!/usr/bin/env bash is the best way in my opinion.
Also, I'm not at all an expert with nix but I imagine it is standard to patch bash scripts when packaging, see e.g. https://ertt.ca/nix/shell-scripts/#orgcdf8a6f
This script is not in nixpkgs and i didn't make a nix package for it on my system. I just downloaded it and added it to my PATH.
The problem was/is, that my SHELL environment variable is set to nu and thus this script failed. The suggested improvement to hardcode bash or employ some other workaround is valid and has got nothing to do with Nixos. It can happen on every other system that has set the SHELL environment variable to something other than bash (zsh probably works as well).
@Schweber I wasn't responding to you with my last comment, if it wasn't clear from the quote; I was trying to understand @medv's point.