make shell-check happy

This commit is contained in:
Jörg Thalheim 2019-10-21 15:05:15 +01:00
parent 28854ee129
commit 9ce7643b1b
No known key found for this signature in database
GPG key ID: B3F5D81B0C6967C4

View file

@ -1,15 +1,23 @@
#!/usr/bin/env bash
use_nix() { use_nix() {
local path="$(nix-instantiate --find-file nixpkgs)" local path
path="$(nix-instantiate --find-file nixpkgs)"
if [[ "${direnv:-}" == "" ]]; then
log_status "\$direnv environment variable was not defined. Was this script run inside direnv?"
fi
local version local version
if [[ -f "${path}/.version-suffix" ]]; then if [[ -f "${path}/.version-suffix" ]]; then
read version < "${path}/.version-suffix" read -r version < "${path}/.version-suffix"
elif [[ -f "${path}/.git/HEAD" ]]; then elif [[ -f "${path}/.git/HEAD" ]]; then
local head local head
read head < "${path}/.git/HEAD" read -r head < "${path}/.git/HEAD"
local regex="ref: (.*)" local regex="ref: (.*)"
if [[ "$head" =~ $regex ]]; then if [[ "$head" =~ $regex ]]; then
read version < ".git/${BASH_REMATCH[1]}" read -r version < ".git/${BASH_REMATCH[1]}"
else else
version="$head" version="$head"
fi fi
@ -25,8 +33,9 @@ use_nix() {
[[ shell.nix -nt "$cache" ]]; [[ shell.nix -nt "$cache" ]];
then then
[[ -d .direnv ]] || mkdir .direnv [[ -d .direnv ]] || mkdir .direnv
local dump_cmd="echo -n _____direnv_____; \"$direnv\" dump bash" local dump_cmd tmp
local tmp=$(nix-shell --show-trace --pure "$@" \ dump_cmd="echo -n _____direnv_____; \"$direnv\" dump bash"
tmp=$(nix-shell --show-trace --pure "$@" \
--run "$dump_cmd" | grep -oP '(?<=_____direnv_____).*') --run "$dump_cmd" | grep -oP '(?<=_____direnv_____).*')
echo "$tmp" > "$cache" echo "$tmp" > "$cache"
update_drv=1 update_drv=1
@ -56,9 +65,9 @@ use_nix() {
fi fi
# This part is based on https://discourse.nixos.org/t/what-is-the-best-dev-workflow-around-nix-shell/418/4 # This part is based on https://discourse.nixos.org/t/what-is-the-best-dev-workflow-around-nix-shell/418/4
if [[ "$out" ]] && (( $update_drv )); then if [[ "${out:-}" != "" ]] && (( update_drv )); then
local drv_link=".direnv/drv" local drv_link=".direnv/drv" drv
local drv="$(nix show-derivation $out | grep -E -o -m1 '/nix/store/.*.drv')" drv=$(nix show-derivation "$out" | grep -E -o -m1 '/nix/store/.*.drv')
local stripped_pwd=${PWD/\//} local stripped_pwd=${PWD/\//}
local escaped_pwd=${stripped_pwd//-/--} local escaped_pwd=${stripped_pwd//-/--}
local escaped_pwd=${escaped_pwd//\//-} local escaped_pwd=${escaped_pwd//\//-}