Skip to content

Commit

Permalink
[spec/nix-idioms] Demonstrate another bash inconsistency
Browse files Browse the repository at this point in the history
Between strings and arrays with ${!ref}

Unrelated: some Docker image analysis.
  • Loading branch information
Andy C committed Dec 8, 2021
1 parent e7a0480 commit dc1ee48
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
21 changes: 21 additions & 0 deletions soil/images.sh
Expand Up @@ -48,4 +48,25 @@ mount-test() {
oilshell/soil-$name sh -c 'ls -l /app'
}

# This shows CREATED, command CREATED BY, size
# It's a human readable size though
#
# This doesn't really have anything better
# https://gist.github.com/MichaelSimons/fb588539dcefd9b5fdf45ba04c302db6
#
# It's annoying that the remote registry API is different than the local API.

layers() {
local name=${1:-dummy}

# Gah this still prints 237M, not the exact number of bytes!
# --format ' {{ .Size }} '
sudo docker history --no-trunc oilshell/soil-$name

echo $'Size\tVirtual Size'
sudo docker inspect oilshell/soil-$name \
| jq --raw-output '.[0] | [.Size, .VirtualSize] | @tsv' \
| commas
}

"$@"
16 changes: 16 additions & 0 deletions spec/nix-idioms.test.sh
Expand Up @@ -95,3 +95,19 @@ done
## STDOUT:
[]
## END

#### Undefined string var is fatal, INCONSISTENT with array
hookSlice='preHooks'

argv.py ${!hookSlice}

set -u

argv.py ${!hookSlice}

echo end

## status: 1
## STDOUT:
[]
## END

0 comments on commit dc1ee48

Please sign in to comment.