diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2021-01-21 17:30:26 +0100 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2021-01-22 10:35:02 +0100 |
commit | d9367a2dd1f2cfe163b9c42e83a0569808ce6fc9 (patch) | |
tree | 253491827b0b394965b0b9d5f41ac3799a6a5ea9 /scripts/install-nix-from-closure.sh | |
parent | 259100332f96250d6615d5839f6a77798c77aefb (diff) |
scripts/install-nix-from-closure: only show progress if a terminal is used
While the progress dots during the copying of the store work fine on a
normal terminal, those look pretty off if the script is run inside a
provisioning script of e.g. `vagrant` or `packer` where `stderr` and
`stdout` are captured:
default: .
default: ..
default: .
default: .
default: .
To work around this, the script checks with `-t 0` if it's
running on an actual terminal and doesn't show the progress if that's not
the case.
Diffstat (limited to 'scripts/install-nix-from-closure.sh')
-rw-r--r-- | scripts/install-nix-from-closure.sh | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/scripts/install-nix-from-closure.sh b/scripts/install-nix-from-closure.sh index 6352a8fac..0ee7ce5af 100644 --- a/scripts/install-nix-from-closure.sh +++ b/scripts/install-nix-from-closure.sh @@ -166,9 +166,15 @@ fi mkdir -p $dest/store printf "copying Nix to %s..." "${dest}/store" >&2 +# Insert a newline if no progress is shown. +if [ ! -t 0 ]; then + echo "" +fi for i in $(cd "$self/store" >/dev/null && echo ./*); do - printf "." >&2 + if [ -t 0 ]; then + printf "." >&2 + fi i_tmp="$dest/store/$i.$$" if [ -e "$i_tmp" ]; then rm -rf "$i_tmp" |