Skip to content

Conversation

@jfp-cs
Copy link

@jfp-cs jfp-cs commented Jan 13, 2026

Problem

When editing PHP files on Debian-based systems (including dev containers), the extension throws repeated "Bad substitution" errors in the output log.

This occurs because:

  • Debian/Ubuntu use dash as /bin/sh, not bash
  • Dash doesn't support bash-style variable substitution syntax
  • PHP code containing patterns like \${$variable} (common for currency formatting) triggers the error
  • The error appears when the extension analyzes PHP files

Example error:
2026-01-13 08:27:49.807 [error] /bin/sh: 1: Bad substitution

Solution

  • parser.ts: Changed from exec() to execFile() to bypass shell interpretation entirely
  • php.ts: Explicitly use /bin/bash for spawn() and exec() on Unix systems
  • pint.ts: Explicitly use /bin/bash for exec() on Unix systems

Consistent approach across all files: undefined for Windows (let Node choose), /bin/bash for Unix.

Testing

Tested in a Debian 11 dev container with PHP files containing \${$var} patterns - errors no longer appear.

Fixes 'Bad substitution' errors when editing PHP files containing
\${...} patterns on Debian-based systems where /bin/sh is dash.

Problem:
- Debian/Ubuntu use dash as /bin/sh, not bash
- Dash doesn't support bash-style variable substitution
- PHP code with patterns like \${$variable} triggered errors
- Common in string concatenation for currency: '$' . $amount

Solution:
- parser.ts: Use execFile() instead of exec() to bypass shell entirely
- php.ts: Explicitly use /bin/bash for spawn() and exec() on Unix
- pint.ts: Explicitly use /bin/bash for exec() on Unix
- Consistent approach: undefined for Windows, /bin/bash for Unix

This ensures the extension works correctly in dev containers and
CI environments using Debian/Ubuntu base images.
@jfp-cs
Copy link
Author

jfp-cs commented Jan 13, 2026

I believe this fixes #157 and #472

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.

1 participant