If you want your program to detect when it's being run by chef, here's one way to do that.
sleep 1 while $ENV{PATH} =~ m#chef[^:]+/bin#;
This works because Chef's shell_out
adds Gem.bindir
to PATH
,
which is something like /opt/chefdk/embedded/bin
.
You may want to delete the "sleep", which will make it run faster.
Would I or anyone ever really do this? Chef Inc's management seems determined to test the question, don't they.
A quick standard for when you want to embed an arbitrary program in the version number of your program.
2 increment the data pointer (to point to the next cell to the right).
3 decrement the data pointer (to point to the next cell to the left).
+ increment (increase by one) the byte at the data pointer.
- decrement (decrease by one) the byte at the data pointer.
. output the byte at the data pointer.
4 accept one byte of input, storing its value in the byte at the data pointer.
6 if the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching 9 command.
9 if the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching 6 command.
This is simply Brainfuck with operators that are legal in (Debian) version numbers kept as-is, and some numbers replacing the rest.
Note that all other operators are ignored as usual. In particular, 1 and 8 are ignored, which make it easy to build version number programs that compare properly with past versions. And in some cases, adding 1 or 8 will be needed to make a particular program be a properly formatted version number.
For example, an infinite loop version number is:
1+69
A nice short hello world is:
1+6-6336+6-8-1-29-6333999222-92-1.1-1-1-8.2.8.2.3333-1.3+1.22222.2.33.3-1.1
Licensing: Yes, there should also be a way to embed a license in a version ... Oh, I mean to say, the Wikipedia excerpt above is CC-BY-SA, and the hello world is based on https://esolangs.org/wiki/Hello_world_program_in_esoteric_languages
Previously: a brainfuck monad