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

ZSH support for hexadecimal and octal literals isn't POSIX compliant #160

Open
laurenthuberdeau opened this issue Feb 20, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@laurenthuberdeau
Copy link
Collaborator

Hexadecimal

ZSH rewrites hexadecimal to base#literal which then breaks the [ command because it expects the operands to in base 10 (without the 10x prefix). This can be fixed by wrapping the hexadecimal literal in an arithmetic expansion to force the conversion to base 10.

Small example showing the issue:

: $((foo = 1))
: $((foo += 0x10))
echo "$foo"
[ "$foo" -ne 0 ]

Octal

ZSH doesn't parse octal literals (with a leading 0) unless the OCTAL_ZEROES option is enabled.

@laurenthuberdeau laurenthuberdeau changed the title ZSH doesn't work well with hexadecimal and octal literals ZSH support for hexadecimal and octal literals isn't POSIX compliant Feb 20, 2025
@laurenthuberdeau laurenthuberdeau added the bug Something isn't working label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant