buildah icon indicating copy to clipboard operation
buildah copied to clipboard

Providing shell to heredoc causes backticks in comments to be run

Open staticfloat opened this issue 1 year ago • 3 comments

Perhaps I'm doing something silly here, but when I build the following:

FROM ubuntu

RUN <<-EOF /bin/bash
    # `command_not_found`
    echo true
EOF

I get output clearly showing that command_not_found was attempted to be run.

$ buildah build
STEP 1/2: FROM ubuntu
STEP 2/2: RUN <<-EOF /bin/bash (# `command_not_found`...)
/bin/sh: 1: command_not_found: not found
true
COMMIT
Getting image source signatures
Copying blob 4b7c01ed0534 skipped: already exists  
Copying blob e55fa0c2935e done   | 
Copying config 883def037e done   | 
Writing manifest to image destination
--> 883def037e6f
883def037e6faea3b6058034300d437fe97249d151a8ee992ed1ba6c552ec975

This can have pretty severely unintended consequences. I will note that docker build does not seem to do this.

This is tested on the latest main buildah.

staticfloat avatar Mar 08 '25 01:03 staticfloat

@staticfloat RUN <<-EOF /bin/bash (# command_not_found...) just shows that following RUN instruction is a heredoc and it shows summary for first few lines. I think buildkit does it as well ?

flouthoc avatar Mar 19 '25 15:03 flouthoc

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Apr 19 '25 00:04 github-actions[bot]

Sorry for the late reply, this got lost in my inbox.

The issue is not with the line:

STEP 2/2: RUN <<-EOF /bin/bash (# `command_not_found`...)

but rather the line underneath that:

/bin/sh: 1: command_not_found: not found

staticfloat avatar Jun 11 '25 20:06 staticfloat