724
you are viewing a single comment's thread
view the rest of the comments
[-] Scoopta@programming.dev 114 points 4 months ago

...this is so much more cursed than it needs to be. If you want to bash in C just system("echo hello world");

[-] tempest@lemmy.ca 58 points 4 months ago

That wouldn't necessarily be bash though

[-] smeg@feddit.uk 58 points 4 months ago

Fine, system("bash -c 'echo hello world'"); then!

[-] xthexder@l.sw0.com 10 points 4 months ago

Now print "¯\_(ツ)_/¯" with the quotes

[-] ultrafastsloth@lemmy.world 16 points 4 months ago

I decided to throw my PC in the composter and become a gardener

[-] Beanie@programming.dev 4 points 4 months ago

my best guess: system("bash -c 'echo \\\"¯\\\\_(ツ)_/¯\\\"'");

which will get parsed as: bash -c 'echo \"¯\\_(ツ)_/¯\"'

which will run: echo "¯\_(ツ)_/¯"

and since echo just prints whatever was given to it, it'll print "¯\_(ツ)_/¯" with the quotes

[-] smeg@feddit.uk 3 points 4 months ago

That was actually the first line of C I've ever written so there's no way I'm guessing the right number of escapes, but I guess I'd cheat by finding the value of each char and printing those one at a time.

[-] Scoopta@programming.dev 21 points 4 months ago

Fair, should've just said shell

this post was submitted on 12 Mar 2025
724 points (98.4% liked)

Programmer Humor

25009 readers
1308 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS