[PR #8] [MERGED] Fix JSON parsing error and interactive prompt hang in install.sh #95

Closed
opened 2026-05-06 13:13:19 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/bwya77/vscode-dark-islands/pull/8
Author: @mayur1377
Created: 2/15/2026
Status: Merged
Merged: 2/15/2026
Merged by: @bwya77

Base: mainHead: fix-json-parsing-error


📝 Commits (1)

  • 073c898 Fix JSON parsing error and interactive prompt hang in install.sh

📊 Changes

1 file changed (+7 additions, -4 deletions)

View changed files

📝 install.sh (+7 -4)

📄 Description

Issue

The installer was failing with a JSON parsing error:

SyntaxError: Bad control character in string literal in JSON at position 4015
    "vbscript": "cscript //Nologo"

This occurred when the existing VS Code settings.json contained double slashes (//) inside string values, which the stripJsonc() function incorrectly treated as comments and removed, corrupting the JSON structure.

Additionally, the script would hang indefinitely when run in non-interactive environments due to the read -p prompt.

Root Cause

  1. The regex /\/\/.*$/gm was removing // from inside JSON strings, not just comments
  2. The interactive prompt read -p blocked execution in non-interactive shells

Fix

  1. Updated stripJsonc() regex to /\/\/(?=(?:[^"\\]|\\.)*$)/gm to only remove // that are actual comments (not inside strings)
  2. Added terminal check if [ -t 0 ] before interactive prompt to prevent hanging
  3. Added better error handling with separate variable for file reading
✓ Fonts installed to Font Book
   Note: You may need to restart applications to use the new fonts

⚙️  Step 4: Applying VS Code settings...
⚠️  Existing settings.json found
   Backing up to settings.json.backup
   Merging Islands Dark settings with your existing settings...
<anonymous_script>:102
    "vbscript": "cscript 

SyntaxError: Bad control character in string literal in JSON at position 4015
    at JSON.parse (<anonymous>)
    at [stdin]:26:31
    at runScriptInThisContext (node:internal/vm:209:10)
    at node:internal/process/execution:118:14
    at [stdin]-wrapper:6:24
    at runScript (node:internal/process/execution:101:62)
    at evalScript (node:internal/process/execution:133:3)
    at node:internal/main/eval_stdin:32:5
    at Socket.<anonymous> (node:internal/process/e
xecution:234:5)
    at Socket.emit (node:events:536:35)
   
Screenshot 2026-02-16 at 1 41 23 AM

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bwya77/vscode-dark-islands/pull/8 **Author:** [@mayur1377](https://github.com/mayur1377) **Created:** 2/15/2026 **Status:** ✅ Merged **Merged:** 2/15/2026 **Merged by:** [@bwya77](https://github.com/bwya77) **Base:** `main` ← **Head:** `fix-json-parsing-error` --- ### 📝 Commits (1) - [`073c898`](https://github.com/bwya77/vscode-dark-islands/commit/073c898efbfc022238cdc7d9b99a7fb392e0bee2) Fix JSON parsing error and interactive prompt hang in install.sh ### 📊 Changes **1 file changed** (+7 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `install.sh` (+7 -4) </details> ### 📄 Description ## Issue The installer was failing with a JSON parsing error: ``` SyntaxError: Bad control character in string literal in JSON at position 4015 "vbscript": "cscript //Nologo" ``` This occurred when the existing VS Code settings.json contained double slashes (//) inside string values, which the stripJsonc() function incorrectly treated as comments and removed, corrupting the JSON structure. Additionally, the script would hang indefinitely when run in non-interactive environments due to the `read -p` prompt. ## Root Cause 1. The regex `/\/\/.*$/gm` was removing `//` from inside JSON strings, not just comments 2. The interactive prompt `read -p` blocked execution in non-interactive shells ## Fix 1. Updated stripJsonc() regex to `/\/\/(?=(?:[^"\\]|\\.)*$)/gm` to only remove `//` that are actual comments (not inside strings) 2. Added terminal check `if [ -t 0 ]` before interactive prompt to prevent hanging 3. Added better error handling with separate variable for file reading ``` ✓ Fonts installed to Font Book Note: You may need to restart applications to use the new fonts ⚙️ Step 4: Applying VS Code settings... ⚠️ Existing settings.json found Backing up to settings.json.backup Merging Islands Dark settings with your existing settings... <anonymous_script>:102 "vbscript": "cscript SyntaxError: Bad control character in string literal in JSON at position 4015 at JSON.parse (<anonymous>) at [stdin]:26:31 at runScriptInThisContext (node:internal/vm:209:10) at node:internal/process/execution:118:14 at [stdin]-wrapper:6:24 at runScript (node:internal/process/execution:101:62) at evalScript (node:internal/process/execution:133:3) at node:internal/main/eval_stdin:32:5 at Socket.<anonymous> (node:internal/process/e xecution:234:5) at Socket.emit (node:events:536:35) ``` <img width="655" height="279" alt="Screenshot 2026-02-16 at 1 41 23 AM" src="https://github.com/user-attachments/assets/3d0e8ff1-2a1d-452f-8a2f-80c081e6ce9a" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:13:19 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vscode-dark-islands#95
No description provided.