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

Current semicolon handling method compromises rawString value in BashCommand. #9

Open
CreMindES opened this issue Jan 22, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@CreMindES
Copy link
Owner

The current semicolon handling - convertSemicolonsToLexItems - strategy during ParseBashCommandList is flawed, as it modifies the rawString value in the resulting BashCommands.

@CreMindES CreMindES added the bug Something isn't working label Jan 22, 2021
@CreMindES CreMindES reopened this Feb 24, 2021
@tymonx
Copy link

tymonx commented Sep 20, 2021

It seems related. This example fails:

ARG BASE_IMAGE=alpine
ARG BASE_TAG=3.14.2

FROM $BASE_IMAGE:$BASE_TAG

RUN \
    packages="colordiff make curl wget git gcc g++ jq" && \
    if command -v apt-get >/dev/null 2>&1; then \
        apt-get update && \
        apt-get install --yes --no-install-recommends --no-upgrade \
            ${packages:+${packages}} \
            bsdmainutils \
            && \
        apt-get clean && \
        apt-get autoclean && \
        rm -rf /var/lib/apt/lists/*; \
    elif command -v apk >/dev/null 2>&1; then \
        mkdir -p /var/cache/apk && \
        ln -s /var/cache/apk /etc/apk/cache && \
        apk --no-cache update && \
        apk --no-cache add \
            ${packages:+${packages}} \
            util-linux \
            libc-dev \
            musl-dev \
            && \
        apk cache clean; \
    elif command -v dnf >/dev/null 2>&1; then \
        dnf update && \
        dnf install --assumeyes \
            ${packages:+${packages}} \
            util-linux \
            && \
        dnf clean all; \
    elif command -v zypper >/dev/null 2>&1; then \
        zypper update --no-confirm && \
        zypper install --no-confirm \
            ${packages:+${packages}} \
            util-linux \
            && \
        zypper clean --all; \
    fi

The parser.ParseBashCommand function throws a panic:

panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: index out of range [0] with length 0

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

2 participants