mirror of
https://github.com/NixOS/nix.git
synced 2025-12-16 22:11:05 +01:00
nix develop: Apply shellcheck
This commit is contained in:
parent
43ec36cddf
commit
5af644492b
2 changed files with 10 additions and 5 deletions
|
|
@ -108,7 +108,6 @@
|
||||||
# We haven't linted these files yet
|
# We haven't linted these files yet
|
||||||
''^scripts/install-multi-user\.sh$''
|
''^scripts/install-multi-user\.sh$''
|
||||||
''^scripts/install-systemd-multi-user\.sh$''
|
''^scripts/install-systemd-multi-user\.sh$''
|
||||||
''^src/nix/get-env\.sh$''
|
|
||||||
''^tests/functional/ca/build-dry\.sh$''
|
''^tests/functional/ca/build-dry\.sh$''
|
||||||
''^tests/functional/ca/build-with-garbage-path\.sh$''
|
''^tests/functional/ca/build-with-garbage-path\.sh$''
|
||||||
''^tests/functional/ca/common\.sh$''
|
''^tests/functional/ca/common\.sh$''
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
set -e
|
set -e
|
||||||
|
# shellcheck disable=SC1090 # Dynamic sourcing is intentional
|
||||||
if [ -e "$NIX_ATTRS_SH_FILE" ]; then source "$NIX_ATTRS_SH_FILE"; fi
|
if [ -e "$NIX_ATTRS_SH_FILE" ]; then source "$NIX_ATTRS_SH_FILE"; fi
|
||||||
|
|
||||||
export IN_NIX_SHELL=impure
|
export IN_NIX_SHELL=impure
|
||||||
export dontAddDisableDepTrack=1
|
export dontAddDisableDepTrack=1
|
||||||
|
|
||||||
if [[ -n $stdenv ]]; then
|
if [[ -n $stdenv ]]; then
|
||||||
source $stdenv/setup
|
# shellcheck disable=SC1091 # setup file is in nix store
|
||||||
|
source "$stdenv"/setup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Better to use compgen, but stdenv bash doesn't have it.
|
# Better to use compgen, but stdenv bash doesn't have it.
|
||||||
|
|
@ -17,10 +20,10 @@ __dumpEnv() {
|
||||||
|
|
||||||
printf ' "bashFunctions": {\n'
|
printf ' "bashFunctions": {\n'
|
||||||
local __first=1
|
local __first=1
|
||||||
while read __line; do
|
while read -r __line; do
|
||||||
if ! [[ $__line =~ ^declare\ -f\ (.*) ]]; then continue; fi
|
if ! [[ $__line =~ ^declare\ -f\ (.*) ]]; then continue; fi
|
||||||
__fun_name="${BASH_REMATCH[1]}"
|
__fun_name="${BASH_REMATCH[1]}"
|
||||||
__fun_body="$(type $__fun_name)"
|
__fun_body="$(type "$__fun_name")"
|
||||||
if [[ $__fun_body =~ \{(.*)\} ]]; then
|
if [[ $__fun_body =~ \{(.*)\} ]]; then
|
||||||
if [[ -z $__first ]]; then printf ',\n'; else __first=; fi
|
if [[ -z $__first ]]; then printf ',\n'; else __first=; fi
|
||||||
__fun_body="${BASH_REMATCH[1]}"
|
__fun_body="${BASH_REMATCH[1]}"
|
||||||
|
|
@ -37,7 +40,7 @@ __dumpEnv() {
|
||||||
|
|
||||||
printf ' "variables": {\n'
|
printf ' "variables": {\n'
|
||||||
local __first=1
|
local __first=1
|
||||||
while read __line; do
|
while read -r __line; do
|
||||||
if ! [[ $__line =~ ^declare\ (-[^ ])\ ([^=]*) ]]; then continue; fi
|
if ! [[ $__line =~ ^declare\ (-[^ ])\ ([^=]*) ]]; then continue; fi
|
||||||
local type="${BASH_REMATCH[1]}"
|
local type="${BASH_REMATCH[1]}"
|
||||||
local __var_name="${BASH_REMATCH[2]}"
|
local __var_name="${BASH_REMATCH[2]}"
|
||||||
|
|
@ -76,7 +79,9 @@ __dumpEnv() {
|
||||||
elif [[ $type == -a ]]; then
|
elif [[ $type == -a ]]; then
|
||||||
printf '"type": "array", "value": ['
|
printf '"type": "array", "value": ['
|
||||||
local __first2=1
|
local __first2=1
|
||||||
|
# shellcheck disable=SC1087 # Complex array manipulation, syntax is correct
|
||||||
__var_name="$__var_name[@]"
|
__var_name="$__var_name[@]"
|
||||||
|
# shellcheck disable=SC1087 # Complex array manipulation, syntax is correct
|
||||||
for __i in "${!__var_name}"; do
|
for __i in "${!__var_name}"; do
|
||||||
if [[ -z $__first2 ]]; then printf ', '; else __first2=; fi
|
if [[ -z $__first2 ]]; then printf ', '; else __first2=; fi
|
||||||
__escapeString "$__i"
|
__escapeString "$__i"
|
||||||
|
|
@ -142,6 +147,7 @@ __dumpEnvToOutput() {
|
||||||
# array with a format like `outname => /nix/store/hash-drvname-outname`.
|
# array with a format like `outname => /nix/store/hash-drvname-outname`.
|
||||||
# Otherwise it is a space-separated list of output variable names.
|
# Otherwise it is a space-separated list of output variable names.
|
||||||
if [ -e "$NIX_ATTRS_SH_FILE" ]; then
|
if [ -e "$NIX_ATTRS_SH_FILE" ]; then
|
||||||
|
# shellcheck disable=SC2154 # outputs is set by sourced file
|
||||||
for __output in "${outputs[@]}"; do
|
for __output in "${outputs[@]}"; do
|
||||||
__dumpEnvToOutput "$__output"
|
__dumpEnvToOutput "$__output"
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue