diff --git a/examples/nerdctl-ipfs-registry-kubernetes/ipfs-cluster/bootstrap.yaml.sh b/examples/nerdctl-ipfs-registry-kubernetes/ipfs-cluster/bootstrap.yaml.sh index cc1b29f579e..e77c9a7105e 100755 --- a/examples/nerdctl-ipfs-registry-kubernetes/ipfs-cluster/bootstrap.yaml.sh +++ b/examples/nerdctl-ipfs-registry-kubernetes/ipfs-cluster/bootstrap.yaml.sh @@ -28,7 +28,7 @@ done TMPIDFILE=$(mktemp) BOOTSTRAP_KEY=$(ipfs-key 2>"${TMPIDFILE}" | base64 -w 0) -ID=$(cat "${TMPIDFILE}" | grep "ID " | sed -E 's/[^:]*: (.*)/\1/') +ID=$(grep "ID " "${TMPIDFILE}" | sed -E 's/[^:]*: (.*)/\1/') rm "${TMPIDFILE}" BOOTSTRAP_PEER_PRIV_KEY=$(echo "${BOOTSTRAP_KEY}" | base64 -w 0) diff --git a/examples/nerdctl-ipfs-registry-kubernetes/ipfs-stargz-snapshotter/bootstrap.yaml.sh b/examples/nerdctl-ipfs-registry-kubernetes/ipfs-stargz-snapshotter/bootstrap.yaml.sh index 8905f617171..fc06a298e26 100755 --- a/examples/nerdctl-ipfs-registry-kubernetes/ipfs-stargz-snapshotter/bootstrap.yaml.sh +++ b/examples/nerdctl-ipfs-registry-kubernetes/ipfs-stargz-snapshotter/bootstrap.yaml.sh @@ -19,12 +19,10 @@ set -eu -o pipefail -for d in ipfs-swarm-key-gen ; do - if ! command -v $d >/dev/null 2>&1 ; then - echo "$d not found" - exit 1 - fi -done +if ! command -v ipfs-swarm-key-gen >/dev/null 2>&1 ; then + echo "ipfs-swarm-key-gen not found" + exit 1 +fi SWARM_KEY=$(ipfs-swarm-key-gen | base64 | tr -d '\n') diff --git a/examples/nerdctl-ipfs-registry-kubernetes/ipfs/bootstrap.yaml.sh b/examples/nerdctl-ipfs-registry-kubernetes/ipfs/bootstrap.yaml.sh index 8905f617171..fc06a298e26 100755 --- a/examples/nerdctl-ipfs-registry-kubernetes/ipfs/bootstrap.yaml.sh +++ b/examples/nerdctl-ipfs-registry-kubernetes/ipfs/bootstrap.yaml.sh @@ -19,12 +19,10 @@ set -eu -o pipefail -for d in ipfs-swarm-key-gen ; do - if ! command -v $d >/dev/null 2>&1 ; then - echo "$d not found" - exit 1 - fi -done +if ! command -v ipfs-swarm-key-gen >/dev/null 2>&1 ; then + echo "ipfs-swarm-key-gen not found" + exit 1 +fi SWARM_KEY=$(ipfs-swarm-key-gen | base64 | tr -d '\n') diff --git a/extras/rootless/containerd-rootless-setuptool.sh b/extras/rootless/containerd-rootless-setuptool.sh index 747d5c41c87..27627640d51 100755 --- a/extras/rootless/containerd-rootless-setuptool.sh +++ b/extras/rootless/containerd-rootless-setuptool.sh @@ -29,19 +29,15 @@ set -eu # utility functions INFO() { - # https://github.com/koalaman/shellcheck/issues/1593 - # shellcheck disable=SC2039 - /bin/echo -e "\e[104m\e[97m[INFO]\e[49m\e[39m ${*}" + printf "\e[104m\e[97m[INFO]\e[49m\e[39m %s\n" "$*" } WARNING() { - # shellcheck disable=SC2039 - /bin/echo >&2 -e "\e[101m\e[97m[WARNING]\e[49m\e[39m ${*}" + >&2 printf "\e[101m\e[97m[WARNING]\e[49m\e[39m %s\n" "$*" } ERROR() { - # shellcheck disable=SC2039 - /bin/echo >&2 -e "\e[101m\e[97m[ERROR]\e[49m\e[39m ${*}" + >&2 printf "\e[101m\e[97m[ERROR]\e[49m\e[39m %s\n" "$*" } # constants @@ -143,8 +139,8 @@ propagate_env_from() { pid="$1" env="$(sed -e "s/\x0/'\n/g" <"/proc/${pid}/environ" | sed -Ee "s/^[^=]*=/export \0'/g")" shift - for key in $@; do - eval $(echo "$env" | grep "^export ${key=}") + for key in "$@"; do + eval "$(echo "$env" | grep "^export ${key=}")" done } diff --git a/extras/rootless/containerd-rootless.sh b/extras/rootless/containerd-rootless.sh index eff0e4241ea..f569484a574 100755 --- a/extras/rootless/containerd-rootless.sh +++ b/extras/rootless/containerd-rootless.sh @@ -60,14 +60,14 @@ fi : "${XDG_DATA_HOME:=$HOME/.local/share}" : "${XDG_CONFIG_HOME:=$HOME/.config}" -if [ -z $_CONTAINERD_ROOTLESS_CHILD ]; then +if [ -z "$_CONTAINERD_ROOTLESS_CHILD" ]; then if [ "$(id -u)" = "0" ]; then echo "Must not run as root" exit 1 fi case "$1" in "check" | "install" | "uninstall") - echo "Did you mean 'containerd-rootless-setuptool.sh $@' ?" + echo "Did you mean 'containerd-rootless-setuptool.sh $*' ?" exit 1 ;; esac @@ -81,19 +81,19 @@ if [ -z $_CONTAINERD_ROOTLESS_CHILD ]; then : "${CONTAINERD_ROOTLESS_ROOTLESSKIT_DETACH_NETNS:=auto}" net=$CONTAINERD_ROOTLESS_ROOTLESSKIT_NET mtu=$CONTAINERD_ROOTLESS_ROOTLESSKIT_MTU - if [ -z $net ]; then + if [ -z "$net" ]; then if command -v slirp4netns >/dev/null 2>&1; then # If --netns-type is present in --help, slirp4netns is >= v0.4.0. if slirp4netns --help | grep -qw -- --netns-type; then net=slirp4netns - if [ -z $mtu ]; then + if [ -z "$mtu" ]; then mtu=65520 fi else echo "slirp4netns found but seems older than v0.4.0. Falling back to VPNKit." fi fi - if [ -z $net ]; then + if [ -z "$net" ]; then if command -v vpnkit >/dev/null 2>&1; then net=vpnkit else @@ -102,7 +102,7 @@ if [ -z $_CONTAINERD_ROOTLESS_CHILD ]; then fi fi fi - if [ -z $mtu ]; then + if [ -z "$mtu" ]; then mtu=1500 fi @@ -120,12 +120,12 @@ if [ -z $_CONTAINERD_ROOTLESS_CHILD ]; then case "$CONTAINERD_ROOTLESS_ROOTLESSKIT_DETACH_NETNS" in auto) - if rootlesskit --help | grep -qw -- "--detach-netns"; then - CONTAINERD_ROOTLESS_ROOTLESSKIT_FLAGS=--detach-netns $CONTAINERD_ROOTLESS_ROOTLESSKIT_FLAGS + if rootlesskit --help | grep -qw -- "--detach-netns"; then + CONTAINERD_ROOTLESS_ROOTLESSKIT_FLAGS="--detach-netns $CONTAINERD_ROOTLESS_ROOTLESSKIT_FLAGS" fi ;; 1 | true) - CONTAINERD_ROOTLESS_ROOTLESSKIT_FLAGS=--detach-netns $CONTAINERD_ROOTLESS_ROOTLESSKIT_FLAGS + CONTAINERD_ROOTLESS_ROOTLESSKIT_FLAGS="--detach-netns $CONTAINERD_ROOTLESS_ROOTLESSKIT_FLAGS" ;; 0 | false) # NOP @@ -144,18 +144,19 @@ if [ -z $_CONTAINERD_ROOTLESS_CHILD ]; then # (by either systemd-networkd or NetworkManager) # * /run: copy-up is required so that we can create /run/containerd (hardcoded) in our namespace # * /var/lib: copy-up is required so that we can create /var/lib/containerd in our namespace + # shellcheck disable=SC2086 exec rootlesskit \ - --state-dir=$CONTAINERD_ROOTLESS_ROOTLESSKIT_STATE_DIR \ - --net=$net --mtu=$mtu \ - --slirp4netns-sandbox=$CONTAINERD_ROOTLESS_ROOTLESSKIT_SLIRP4NETNS_SANDBOX \ - --slirp4netns-seccomp=$CONTAINERD_ROOTLESS_ROOTLESSKIT_SLIRP4NETNS_SECCOMP \ - --disable-host-loopback --port-driver=$CONTAINERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER \ + --state-dir="$CONTAINERD_ROOTLESS_ROOTLESSKIT_STATE_DIR" \ + --net="$net" --mtu="$mtu" \ + --slirp4netns-sandbox="$CONTAINERD_ROOTLESS_ROOTLESSKIT_SLIRP4NETNS_SANDBOX" \ + --slirp4netns-seccomp="$CONTAINERD_ROOTLESS_ROOTLESSKIT_SLIRP4NETNS_SECCOMP" \ + --disable-host-loopback --port-driver="$CONTAINERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER" \ --copy-up=/etc --copy-up=/run --copy-up=/var/lib \ --propagation=rslave \ $CONTAINERD_ROOTLESS_ROOTLESSKIT_FLAGS \ - $0 $@ + "$0" "$@" else - [ $_CONTAINERD_ROOTLESS_CHILD = 1 ] + [ "$_CONTAINERD_ROOTLESS_CHILD" = 1 ] # Remove the *symlinks* for the existing files in the parent namespace if any, # so that we can create our own files in our mount namespace. # The actual files in the parent namespace are *not removed* by this rm command. @@ -193,5 +194,5 @@ else chcon system_u:object_r:iptables_var_run_t:s0 /run fi - exec containerd $@ + exec containerd "$@" fi diff --git a/hack/generate-release-note.sh b/hack/generate-release-note.sh index 87ce76b3f55..70276919be3 100755 --- a/hack/generate-release-note.sh +++ b/hack/generate-release-note.sh @@ -17,8 +17,8 @@ minimal_amd64tgz="$(find _output -name '*linux-amd64.tar.gz*' -and ! -name '*full*')" full_amd64tgz="$(find _output -name '*linux-amd64.tar.gz*' -and -name '*full*')" -minimal_amd64tgz_basename="$(basename ${minimal_amd64tgz})" -full_amd64tgz_basename="$(basename ${full_amd64tgz})" +minimal_amd64tgz_basename="$(basename "${minimal_amd64tgz}")" +full_amd64tgz_basename="$(basename "${full_amd64tgz}")" cat <<-EOX ## Changes @@ -37,7 +37,7 @@ Extract the archive to a path like \`/usr/local/bin\` or \`~/bin\` .

\`\`\` -$(tar tzvf ${minimal_amd64tgz}) +$(tar tzvf "${minimal_amd64tgz}") \`\`\`

@@ -49,7 +49,7 @@ Extract the archive to a path like \`/usr/local\` or \`~/.local\` .

\`\`\` -$(tar tzvf ${full_amd64tgz}) +$(tar tzvf "${full_amd64tgz}") \`\`\`

@@ -59,7 +59,7 @@ $(tar tzvf ${full_amd64tgz}) See \`share/doc/nerdctl-full/README.md\`: \`\`\`markdown -$(tar xOzf ${full_amd64tgz} share/doc/nerdctl-full/README.md) +$(tar xOzf "${full_amd64tgz}" share/doc/nerdctl-full/README.md) \`\`\`