-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix(shell): two parse errors — missing ';' before '}', and shell logic inside an array literal #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,57 +124,58 @@ | |
| echo "" | ||
|
|
||
| # Construct nerdctl run command | ||
| NERDCTL_ARGS=( | ||
| run | ||
| --rm | ||
| --interactive | ||
|
|
||
| # Resource limits (matching system) | ||
| --memory="${CONTAINER_MEM_LIMIT}" | ||
| --memory-swap="$((CONTAINER_MEM_LIMIT + CONTAINER_SWAP_LIMIT))" | ||
| --cpus="${CONTAINER_CPUS}" | ||
| --pids-limit="${PID_LIMIT}" | ||
|
|
||
| # Security constraints | ||
| --security-opt=no-new-privileges | ||
| --cap-drop=ALL | ||
| --read-only | ||
| --network=none | ||
|
|
||
| # ulimits | ||
| --ulimit="nofile=${NOFILE_LIMIT}:${NOFILE_LIMIT}" | ||
| --ulimit="nproc=${NPROC_LIMIT}:${NPROC_LIMIT}" | ||
|
|
||
| # Temporary filesystems | ||
| --tmpfs=/tmp:rw,noexec,nosuid,size=64m | ||
| --tmpfs=/run:rw,noexec,nosuid,size=16m | ||
| --tmpfs=/home/"$(whoami)"/.cache:rw,noexec,nosuid,size=32m | ||
|
|
||
| # Mount home directory READ-ONLY for validation | ||
| --volume="${HOME}:${HOME}:ro" | ||
|
|
||
| # Mount specific config directories | ||
| --volume="${HOME}/.bashrc:${HOME}/.bashrc:ro" | ||
| --volume="${HOME}/.bashrc.d:${HOME}/.bashrc.d:ro" | ||
| --volume="${HOME}/.config:${HOME}/.config:ro" | ||
| --volume="${HOME}/.local:${HOME}/.local:ro" | ||
|
|
||
| # Mount asdf if present | ||
| ${HOME}/.asdf && --volume="${HOME}/.asdf:${HOME}/.asdf:ro" | ||
|
|
||
| # Environment | ||
| --env="HOME=${HOME}" | ||
| --env="USER=$(whoami)" | ||
| --env="SHELL=/bin/bash" | ||
| --env="TERM=${TERM:-xterm-256color}" | ||
|
|
||
| # User | ||
| --user="$(id -u):$(id -g)" | ||
|
|
||
| # Image | ||
| "$IMAGE_NAME" | ||
| ) | ||
|
|
||
| # Mount asdf only if present (cannot be expressed inside the array literal above) | ||
| [ -d "${HOME}/.asdf" ] && NERDCTL_ARGS+=( --volume="${HOME}/.asdf:${HOME}/.asdf:ro" ) | ||
|
Comment on lines
+176
to
+177
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
tmp_home=$(mktemp -d)
trap 'rm -rf "$tmp_home"' EXIT
mkdir -p "$tmp_home/.asdf"
HOME="$tmp_home"
IMAGE_NAME="nerdsafe-restart:kinoite"
NERDCTL_ARGS=(run "$IMAGE_NAME")
[ -d "${HOME}/.asdf" ] &&
NERDCTL_ARGS+=(--volume="${HOME}/.asdf:${HOME}/.asdf:ro")
NERDCTL_ARGS=(
"${NERDCTL_ARGS[@]:0:$((${`#NERDCTL_ARGS`[@]}-1))}"
--volume="${HOME}/.asdf:${HOME}/.asdf:ro"
"$IMAGE_NAME"
)
printf '<%s>\n' "${NERDCTL_ARGS[@]}"
test "$(printf '%s\n' "${NERDCTL_ARGS[@]}" | grep -cFx "$IMAGE_NAME")" -eq 1Repository: hyperpolymath/ambientops Length of output: 288 🏁 Script executed: sed -n '160,195p' nerdsafe-restart/run-constrained.shRepository: hyperpolymath/ambientops Length of output: 964 Remove the duplicate When 🤖 Prompt for AI Agents |
||
|
|
||
| # Add asdf mount if directory exists | ||
| if [[ -d "${HOME}/.asdf" ]]; then | ||
| NERDCTL_ARGS=( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 HIGH RISK
This conditional append is redundant and introduces a logic error. The logic for mounting the '.asdf' volume is already implemented in the block at lines 180-186. Adding it here at line 177 appends the
--volumeflag after the$IMAGE_NAME(which was added at line 173), violating the requirement that options precede the image name innerdctl. Furthermore, this causes the subsequent slicing logic to malfunction, resulting in a duplicated image name and a malformed command.Consider refactoring the script to push
$IMAGE_NAMEto the array at the very end (after all conditional logic) so that flags can be added using simple+=syntax without brittle array slicing.