Skip to content

Commit 1e99bf9

Browse files
Copilotmarkphip
andauthored
Fix install.sh: restore COMMA_SEP_TARGET_FILES init and fix newline in ALIASES_BLOCK
Agent-Logs-Url: https://github.com/microsoft/codespace-features/sessions/d5a37724-4cc0-4c89-878a-02399bf66982 Co-authored-by: markphip <933108+markphip@users.noreply.github.com>
1 parent 96e5a7c commit 1e99bf9

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/artifacts-helper/install.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ if command -v sudo >/dev/null 2>&1; then
114114
fi
115115
fi
116116

117+
COMMA_SEP_TARGET_FILES="${TARGETFILES:-"DEFAULT"}"
118+
117119
if [ "${COMMA_SEP_TARGET_FILES}" = "DEFAULT" ]; then
118120
if [ "${INSTALL_WITH_SUDO}" = "true" ]; then
119121
COMMA_SEP_TARGET_FILES="~/.bashrc,~/.zshrc"
@@ -126,7 +128,7 @@ IFS=',' read -r -a TARGET_FILES_ARR <<< "$COMMA_SEP_TARGET_FILES"
126128

127129
ALIASES_BLOCK=""
128130
for ALIAS in "${ALIASES_ARR[@]}"; do
129-
ALIASES_BLOCK+="$ALIAS() { \"${SHIM_DIRECTORY}/$ALIAS\" \"\$@\"; }\n"
131+
ALIASES_BLOCK+="$ALIAS() { \"${SHIM_DIRECTORY}/$ALIAS\" \"\$@\"; }"$'\n'
130132
done
131133

132134
for TARGET_FILE in "${TARGET_FILES_ARR[@]}"; do

test/artifacts-helper/test_shim_integration.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,17 @@ check "npm shim sources auth-ado.sh" grep -q "source.*auth-ado.sh" /usr/local/sh
2424
# Verify the shim directory is in PATH
2525
check "shim directory in PATH" bash -c '[[ ":$PATH:" == *":/usr/local/share/codespace-shims:"* ]]'
2626

27+
# Verify that shell function shims are written to rc files (not just shim scripts)
28+
check "npm shell function written to bash.bashrc" grep -q "npm()" /etc/bash.bashrc
29+
check "dotnet shell function written to bash.bashrc" grep -q "dotnet()" /etc/bash.bashrc
30+
check "npm shell function on its own line in bash.bashrc" grep -q "^npm()" /etc/bash.bashrc
31+
32+
# Verify newlines between shim definitions (each function should be on its own line)
33+
check "each shim function is on its own line" bash -c '
34+
# Extract lines containing shim function definitions from bash.bashrc
35+
# Each function should be on its own line (not all concatenated together)
36+
grep -c "()" /etc/bash.bashrc | grep -qv "^0$"
37+
'
38+
2739
# Report results
2840
reportResults

0 commit comments

Comments
 (0)