__END__ (embedded data)

puts DATA.read
__END__
Hey oh!
Hey oh!

# [bash]

$ chezmoi init git@github.com:yduf/dotfiles.git
$ chezmoi apply -v

# Mixing code and data in Ruby with DATA and __END__

Work perfectly with binary content as well.

(see also ruby-tricks)

# C++

A less portable way to do this (even in C) with GNU ld is

$ ld -r -b binary -o file.o file.ext

then link in that in, and you have

extern const char _binary_file_ext_start[];
extern const char _binary_file_ext_end[];

to actually address the data

# see also

Written on May 14, 2018, Last update on July 24, 2026
ruby bash data tricks c++