Skip to content
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

Error running with numeric environment variable name #10833

Closed
desmana opened this issue Apr 3, 2024 · 5 comments
Closed

Error running with numeric environment variable name #10833

desmana opened this issue Apr 3, 2024 · 5 comments

Comments

@desmana
Copy link

desmana commented Apr 3, 2024

Bug report

Having variables with numeric names being present in the environment results in the following error:

$ env 1=1 ./phpstan
The key of item 'parameters › env › 1' expects to be string, 1 given.

I'm using PHPStan version 1.11.x-dev@a72400b from this repository.

Code snippet that reproduces the problem

No response

Expected output

Program should run normally:

$ env 1=1 ./phpstan
At least one path must be specified to analyse.

Did PHPStan help you today? Did it make you happy in any way?

No response

Copy link

mergeable bot commented Apr 3, 2024

This bug report is missing a link to reproduction at phpstan.org/try.

It will most likely be closed after manual review.

ondrejmirtes added a commit to phpstan/phpstan-src that referenced this issue Apr 4, 2024
@ondrejmirtes
Copy link
Member

Reproduced: phpstan/phpstan-src@24d990b
Fixed: phpstan/phpstan-src@e606fbe

@staabm
Copy link
Contributor

staabm commented Apr 4, 2024

@desmana interessting, I never needed a numeric env var. could you give a bit more detail when/how you need that? I am just curious.

@desmana
Copy link
Author

desmana commented Apr 4, 2024

@staabm CI stack I'm running uses execline script from s6 supervision suite. If you're not familiar, think of execline as a specialized bash alternative for scripting. By default execline sets environment variables 1 2 ... 9 to positional arguments $1 $2 ... $9

I did some research before submitting the report. It's not recommended by POSIX to use such variables:

Other applications may have difficulty dealing with environment variable names that start with a digit. For this reason, use of such names is not recommended anywhere.

They're not trivial to set either. For example bash refuses to accept this:

$ export 1=1
bash: export: `1=1': not a valid identifier

Copy link

github-actions bot commented May 6, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants