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

Escape rightly bash function #270

Open
Mte90 opened this issue Jul 4, 2024 · 0 comments
Open

Escape rightly bash function #270

Mte90 opened this issue Jul 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Mte90
Copy link
Member

Mte90 commented Jul 4, 2024

This required a specific ticket for shellcheck #72
Doing some tests:

pub fun is_command(command: Text): Bool {
    if (unsafe $command -v "{command}" > /dev/null$) {
        return true
    }
    return false
}

Generate this bash:

function is_command__28_v0 {
    local command=$1
    [ -x "$(command -v ${command})" ];
    __AS=$?;
if [ $__AS != 0 ]; then
        __AF_is_command28_v0=0;
        return 0
fi
    __AF_is_command28_v0=1;
    return 0
}

For shellcheck it is wrong, it should be:

function is_command__28_v0 {
    local command=$1
    [ -x $(command -v "${command}") ];
    __AS=$?;
if [ $__AS != 0 ]; then
        __AF_is_command28_v0=0;
        return 0
fi
    __AF_is_command28_v0=1;
    return 0
}

Basically the change:

    [ -x "$(command -v ${command})" ]; //wrong
    [ -x $(command -v "${command}") ]; //right
@Mte90 Mte90 added the bug Something isn't working label Jul 4, 2024
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