fix non-standard shebang

The only paths you can take for granted are `/bin/sh` and
`/usr/bin/env`. Using `/bin/bash` may not work on every system (for
example on NixOS). This commit fixes this by using `/bin/sh` instead.

Signed-off-by: Guillaume Pagnoux <guillaume.pagnoux@lse.epita.fr>
This commit is contained in:
Guillaume Pagnoux 2020-02-01 11:53:41 +01:00
parent d8fb32b4a5
commit 3e1483dcb0
No known key found for this signature in database
GPG key ID: D35934FEC93651BF

View file

@ -1,42 +1,40 @@
#!/bin/bash #!/bin/sh
function main() { chemacs_path=$(realpath "$(dirname "$0")")
if [[ -L "$HOME/.emacs" ]]; then
main() {
if [ -L "$HOME/.emacs" ]; then
check_existing_symlink check_existing_symlink
else else
create_symlink_if_possible create_symlink_if_possible
fi fi
} }
function check_existing_symlink() { check_existing_symlink() {
local target=$(readlink -f $HOME/.emacs) target=$(readlink -f "$HOME/.emacs")
if [[ "$target" != "`chemacs_home`.emacs" ]]; then if [ "$target" != "$chemacs_path/.emacs" ]; then
warn "~/.emacs symlink points elsewhere -> $target" warn "~/.emacs symlink points elsewhere -> $target"
else else
ok "chemacs already linked, you're all good." ok "chemacs already linked, you're all good."
fi fi
} }
function create_symlink_if_possible() { create_symlink_if_possible() {
if [[ -e "$HOME/.emacs" ]]; then if [ -e "$HOME/.emacs" ]; then
warn "chemacs can't be installed, ~/.emacs is in the way" warn "chemacs can't be installed, ~/.emacs is in the way"
else else
ok "Creating symlink ~/.emacs -> `chemacs_home`.emacs" ok "Creating symlink ~/.emacs -> $chemacs_path/.emacs"
ln -s "`chemacs_home`.emacs" "$HOME" ln -s "$chemacs_path/.emacs" "$HOME"
fi fi
} }
function chemacs_home() { warn() {
cd `dirname "${BASH_SOURCE[0]}"` && echo "`pwd`/$1" printf "WARN\t%s\n" "$1"
} }
function warn() { ok() {
echo -e "WARN\t$1" printf "OK\t%s\n" "$1"
} }
function ok() {
echo -e "OK\t$1"
}
main main