this post was submitted on 30 Sep 2024
435 points (97.8% liked)

Programmer Humor

19291 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 1 year ago
MODERATORS
 
top 47 comments
sorted by: hot top controversial new old
[–] MonkderVierte@lemmy.ml 6 points 3 hours ago* (last edited 3 hours ago)

echo $PATH

And alias to be sure.

[–] mycodesucks@lemmy.world 100 points 15 hours ago (2 children)
[–] Gsus4@mander.xyz 2 points 3 hours ago

need to be more creative with aliasing than "ls"

[–] pfm@scribe.disroot.org 62 points 16 hours ago (3 children)
[–] pro3757@programming.dev 3 points 3 hours ago

I got reminded of it last week after years. What are the chances it came up again. 😁

[–] Brahvim@lemmy.kde.social 8 points 10 hours ago

THANKS!!! I have it bookmarked forever now!

I lost access to it. Thank you for bringing it back to me! Yay!...

[–] fibojoly@sh.itjust.works 15 points 15 hours ago (1 children)

That was a beautiful read, cheers!

[–] pfm@scribe.disroot.org 12 points 15 hours ago

If you enjoyed it, I've collected a couple of others:

https://untalkative.one/reading:2019:good-stories

[–] Badabinski@kbin.earth 78 points 18 hours ago (2 children)

Having been in this situation (the only binary I could use was bash, although cd was a bash builtin for me), echo * is your friend. Even better is something like this:

get_path_type() {
    local item
    item="$1"
    [[ -z "$item" ]] && { echo 'wrong arg count passed to get_path_type'; return 1; }
    if [[ -d "$item" ]]; then
        echo 'dir'
    elif [[ -f "$item" ]]; then
        echo 'file'
    elif [[ -h "$item" ]]; then
        echo 'link'  # not accurate, but symlink is too long
    else
        echo '????'
    fi
}

print_path_listing() {
    local path path_type
    path="$1"
    [[ -z "$path" ]] && { echo 'wrong arg count passed to print_path_listing'; return 1; }
    path_type="$(get_path_type "$path")"
    printf '%s\t%s\n' "$path_type" "$path"
}

ls() {
    local path paths item symlink_regex
    paths=("$@")
    if ((${#paths[@]} == 0)); then
        paths=("$(pwd)")
    fi
    shopt -s dotglob
    for path in "${paths[@]}"; do
        if [[ -d "$path" ]]; then
            printf '%s\n' "$path"
            for item in "$path"/*; do
                print_path_listing "$item"
            done
        elif [[ -e "$path" ]]; then
            print_path_listing "$path"
        printf '\n'
        fi
    done
}

This is recreated from memory and will likely have several nasty bugs. I also wrote it and quickly tested it entirely on my phone which was a bit painful. It should be pure bash, so it'll work in this type of situation.

EDIT: I'm bored and sleep deprived and wanted to do something, hence this nonsense. I've taken the joke entirely too seriously.

[–] bi_tux@lemmy.world 4 points 6 hours ago (1 children)

I wanted to try it on my phone to, since I'm bored sitting on my train to work, but appearently you can't copy text out of jeroba and now I don't care enough to open it in my webbrowser

[–] Illecors@lemmy.cafe 1 points 3 minutes ago

FWIW - starting a reply allows you to copy the original text.

[–] MicrowavedTea@infosec.pub 40 points 18 hours ago (1 children)

was a bit painful

Well that's an understatement

[–] Badabinski@kbin.earth 42 points 18 hours ago (2 children)

My pain tolerance for shitty input methods has been permanently warped after experiencing psychic damage from using Teamviewer to connect to a system over a very flaky HughesNet satellite link. I was working for a vendor that supplied a hardware networking box to a stupid retail company that sells food and shit. I just wanted to ssh to our boxen on a specific network so I could troubleshoot something, but the only way I could get to it was via putty installed on an ancient Windows XP desktop on the same network as our box that could only be accessed with Teamviewer. My favorite part of that was that the locale or something was fucked up, so my qwerty keyboard inputs were, like, fucking transformed into azerty somehow?? The Windows desktop was locked down and monitored to a tremendous degree, so I couldn't change anything. The resolution was terrible, the latency was over a second, and half of my keyboard inputs turned into gibberish on the other side.

Oh, and I was onsite at that same company's HQ doing a sales engineering call while I was trying to figure out what was wrong. I spent 5 days sitting in spare offices with shitty chairs, away from my family, living that fucking nightmare before I finally figured out what was wrong. God damn, what a fucking mess that was. For anyone reading this, NEVER WORK FOR GROCERY/DRUG STORE IT. They are worse than fucking banks in some ways. Fuck.

EDIT: also, I asked 'why Teamviewer' and the answer was always shrugs. This was before the big TeamViewer security incidents, so maybe they thought it was more secure? Like, at least they didn't expose RDP on the internet...

[–] Malfeasant@lemm.ee 4 points 12 hours ago (1 children)

HughesNet

the latency was over a second

It's going to space!

[–] Badabinski@kbin.earth 4 points 12 hours ago

It very definitely was 😅 The way that company used the satellite network was cool, don't get me wrong. They would use it to push content out to all their stores with multicast which was really efficient with bandwidth. I loved it for that, but I hated interacting with it over unicast in any way, shape, or form. Horses for courses, as they say.

[–] MicrowavedTea@infosec.pub 14 points 17 hours ago

Yeah, suddenly coding on a phone doesn't seem so bad

[–] Thorry84@feddit.nl 49 points 19 hours ago (5 children)

Hmmm command not found, let me just try the same command a couple more times, this time it will work right?

In IT teaching users to actually read and understand errors is always an uphill battle.

[–] smeg@feddit.uk 1 points 1 hour ago

Never dealt with an intermittent failure or race condition, eh?

[–] Lepsea@sh.itjust.works 8 points 11 hours ago (1 children)

You see they all different one use / the other use - and ~

/S

[–] thevoidzero@lemmy.world 3 points 6 hours ago* (last edited 6 hours ago)

Yeah but those are arguments to cd, the error says command not found

Edit: Sorry didn't see /S

[–] kaboom36@ani.social 72 points 18 hours ago (1 children)

Tbh I'd try it multiple times too, just because the concept of cd not being there is horrifying and cannot possibly be the case

[–] Thorry84@feddit.nl 23 points 18 hours ago

Very true, I would do the same and feel my stomach drop farther each time.

[–] skulbuny@sh.itjust.works 22 points 17 hours ago (3 children)

I learned early in my software engineering career these two beautiful rules of debugging:

  1. Read all of the words
  2. Believe them
[–] smeg@feddit.uk 2 points 1 hour ago (1 children)

Addendum to 2: never believe that what they say is relevant to what's actually happening here. You have a lot of faith that the people writing error messages knew what they were doing!

[–] skulbuny@sh.itjust.works 2 points 1 hour ago* (last edited 1 hour ago)

I mean, if the error says "variable foo is not defined" I don't think it's wise to go "I'm pretty sure it's defined, the compiler is just wrong" 😂

[–] ugo@feddit.it 6 points 13 hours ago

Until you write a compiler error in some deeply templated C++ code, in which case just reading every word takes all day

/s but not too much

[–] elvith@feddit.org 9 points 17 hours ago* (last edited 17 hours ago)

Unless you were the one writing the program and its error messages - then check, that you didn't mess up there...

[–] FruitLips@lemmy.ml 5 points 18 hours ago

Where is the Windows 'help' button, did you try that?

[–] vvv@programming.dev 71 points 20 hours ago (2 children)
[–] fool@programming.dev 37 points 20 hours ago (1 children)

-1 accuracy point ( ◞ ﹏ ◟)

linux 4.5-rc5 had efivarfs fixed to prevent "rm -rf /" bricking uefi motherboards -- so maybe someone can try it out? :]

[–] HighlyRegardedArtist@lemmy.world 4 points 15 hours ago

This is one of the reasons I've disabled uefi by default with the noefi kernel parameter, the other reason being the LogoFAIL exploit: https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface#Disable_UEFI_variable_access

[–] sik0fewl@lemmy.ca 5 points 14 hours ago

It would be pretty useless if cd was a child process that changed its own directory, only to return to bash and be back where you started.

[–] Scoopta@programming.dev 25 points 18 hours ago (3 children)

I am immune to /dev/sda for I only have nvme

[–] redditReallySucks@lemmy.dbzer0.com 24 points 16 hours ago

I love the nvme partition naming. Looking at you nvme1n1p3

[–] nxn@lemmy.ml 11 points 17 hours ago (1 children)

What do you mean? The nvme device label convention is far easier to screw up IMO. At least on my system the first drive would be labeled "nvme0n1", second "nvme1n1", etc and partitions get an additional suffix like "nvme0n1p1".

I am far more likely to screw that up compared to "sda" vs "sdb". Especially since I noticed that if I have both my internal and external SSDs hooked up at boot time their number gets assigned on a seemingly random basis.

[–] Scoopta@programming.dev 7 points 17 hours ago* (last edited 17 hours ago)

Eh? Idk if I agree. My original comment was entirely a joke based on the fact that the literal argument of=/dev/sda has no affect on my system but to address your actual point. I personally don't find nvme naming any more confusing than SCSI. /dev/nvme0n1 is only one char away from /dev/nvme1n1 just like sda vs sdb. Additionally if you understand how the kernel comes up with those names they make a lot of sense. The first number is the controller, the second is the namespace or drive attached to that controller, the 3rd if present is the partition on the given drive. It is entirely possible to have a controller with more than one namespace. That aside aside...I think there is a genuine benefit to be argued for having USB drives, which are SCSI and fall into sdX naming separate from system drives as I dd far more USB media than system media. Making it a lot harder to screw my system up when trying to poke a flash drive.

[–] cmhe@lemmy.world 4 points 17 hours ago* (last edited 17 hours ago)

That might make it even more dangerous, because you get used to flash to usb sticks on "/dev/sda". And when you then use a device with a built-in sata drive, you might forget checking in a hurry.

Happened to me a once or twice. I am now only using bmap tools for this.

[–] nxn@lemmy.ml 30 points 19 hours ago
[–] Shadow@lemmy.ca 34 points 20 hours ago

No problem, just tab complete your way around the filesystem.

[–] nichtburningturtle@feddit.org 13 points 20 hours ago

I see girls last tour, I upvote.

[–] teft@lemmy.world 9 points 19 hours ago

You should all just use an immutable distro. Problemo solved-o.

/s

[–] 0x0@programming.dev 9 points 20 hours ago

Empty $PATH.

[–] aniki@discuss.tchncs.de 6 points 18 hours ago (1 children)

This isn't programming, just someone who sucks at bash.

[–] zero_spelled_with_an_ecks@programming.dev 5 points 17 hours ago (1 children)

How else are you going to open your files in nano to do the programming on the prod server?

[–] aniki@discuss.tchncs.de 3 points 16 hours ago

what's a nano?

[–] mariusafa@lemmy.sdf.org 3 points 19 hours ago* (last edited 19 hours ago)

guix rollback