Skip to content

Fix malformed shell function aliases in artifacts-helper#111

Merged
markphip merged 3 commits intomainfrom
copilot/fix-aliases-malformed
Apr 27, 2026
Merged

Fix malformed shell function aliases in artifacts-helper#111
markphip merged 3 commits intomainfrom
copilot/fix-aliases-malformed

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

When installing as a non-root user, the shell function shims written to rc files were missing path quoting and argument forwarding, producing dotnet() { /usr/local/share/codespace-shims/dotnet ; } instead of dotnet() { "/usr/local/share/codespace-shims/dotnet" "$@"; }.

Root cause

The ALIASES_BLOCK string contains literal " characters. Embedding it inside bash -c "..." caused the outer shell to misparse the quotes during expansion:

# Broken: embedded quotes in $ALIASES_BLOCK corrupt the bash -c argument
sudo -u ${_REMOTE_USER} bash -c "printf '%s' \"$ALIASES_BLOCK\" >> $TARGET_FILE"

The inner bash received a mangled command where the path quotes and "$@" were consumed as shell syntax rather than literal characters.

Changes

  • install.sh: Write ALIASES_BLOCK to a temp file first, then append via cat — eliminating the quoting hazard entirely. Also quotes ${_REMOTE_USER} to prevent word splitting.
_TEMP_BLOCK=$(mktemp)
printf '%s' "$ALIASES_BLOCK" > "$_TEMP_BLOCK"
sudo -u "${_REMOTE_USER}" bash -c "cat '$_TEMP_BLOCK' >> $TARGET_FILE"
rm -f "$_TEMP_BLOCK"
  • test_shim_integration.sh: Added checks that alias definitions in rc files include properly quoted paths and "$@" argument forwarding.
  • devcontainer-feature.json: Bumped version to 3.0.8.

Copilot AI linked an issue Apr 27, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 27, 2026 20:35
Copilot AI changed the title [WIP] Fix malformed alias definitions in artifacts-helper Fix malformed shell function aliases in artifacts-helper Apr 27, 2026
Copilot AI requested a review from markphip April 27, 2026 20:37
@markphip markphip marked this pull request as ready for review April 27, 2026 20:38
@markphip markphip merged commit bdfa977 into main Apr 27, 2026
7 of 16 checks passed
@markphip markphip deleted the copilot/fix-aliases-malformed branch April 27, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aliases malformed

2 participants