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

Braces inside the function definition are broken #95

Open
SivkovSavely opened this issue Jul 8, 2024 · 0 comments
Open

Braces inside the function definition are broken #95

SivkovSavely opened this issue Jul 8, 2024 · 0 comments

Comments

@SivkovSavely
Copy link

The code with a problem is:

catch() {
    {
        IFS=$'\n' read -r -d '' "${1}";
        IFS=$'\n' read -r -d '' "${2}";
        (IFS=$'\n' read -r -d '' _ERRNO_; return ${_ERRNO_});
    } < <((printf '\0%s\0%d\0' "$(((({ shift 2; "${@}"; echo "${?}" 1>&3-; } | tr -d '\0' 1>&4-) 4>&2- 2>&1- | tr -d '\0' 1>&4-) 3>&1- | exit "$(cat)") 4>&1-)" "${?}" 1>&2) 2>&1)
}

It looks like:

Full code:
image
As you can see, some things inside the function check are broken, and after the function definition it's completely broken.

It should look like:

I couldn't fix it completely, but something like this, I guess:
image

The problem is in this part:

"$(((({ shift 2; "${@}"; echo "${?}" 1>&3-; } | tr -d '\0' 1>&4-) 4>&2- 2>&1- | tr -d '\0' 1>&4-) 3>&1- | exit "$(cat)") 4>&1-)"

I honestly don't know what sorcery is used to make this work (this function works the way I need it), but this part breaks the syntax highlight.

Here is the full expression from the last line of the function, minus the } < < part:
image

As you can see, the two opening parentheses in the beginning do not match the closing parentheses in the end (after 1>&2 and 2>&1 respectively), even though they should, because they do when I remove the offending string.

I couldn't figure out what exactly breaks the syntax, you can try removing parts of the offending string and some other parts will be colored differently, but still in a broken way.

Maybe this function's syntax is just too complex for a regex? Or is there no impossible things in regex?

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

No branches or pull requests

1 participant