153 points

Obligatory XKCD

permalink
report
reply
8 points

need to be more creative with aliasing than “ls”

permalink
report
parent
reply
92 points

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.

permalink
report
reply
50 points

was a bit painful

Well that’s an understatement

permalink
report
parent
reply
42 points

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…

permalink
report
parent
reply
14 points

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

permalink
report
parent
reply
4 points

HughesNet

the latency was over a second

It’s going to space!

permalink
report
parent
reply
4 points

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

permalink
report
parent
reply
2 points

Also if you tap on the ‘kebab’ menu and press View Source, you can copy the message.

permalink
report
parent
reply
2 points

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

permalink
report
parent
reply
2 points

TIL

permalink
report
parent
reply
76 points

Reminds me this great story from a different era:

https://www.ee.ryerson.ca/~elf/hack/recovery.html

permalink
report
reply
22 points

That was a beautiful read, cheers!

permalink
report
parent
reply
16 points

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

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

permalink
report
parent
reply
2 points

The final line of the one about the VAX machine is so perfect

permalink
report
parent
reply
8 points

THANKS!!! I have it bookmarked forever now!

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

permalink
report
parent
reply
5 points

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

permalink
report
parent
reply
78 points

… but cd is a built-in

permalink
report
reply
39 points

-1 accuracy point ( ◞ ﹏ ◟)

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

permalink
report
parent
reply
4 points

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

permalink
report
parent
reply
7 points

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.

permalink
report
parent
reply
56 points

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.

permalink
report
reply
77 points

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

permalink
report
parent
reply
25 points

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

permalink
report
parent
reply
2 points

Also muscle memory. I keep typing aliases I only have on my computer :(

permalink
report
parent
reply
23 points

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

  1. Read all of the words
  2. Believe them
permalink
report
parent
reply
6 points

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!

permalink
report
parent
reply
3 points

Having written some error messages in a godforsaken database frontend, an error message only means that something didn’t work correctly and may or may not correctly indicate what is actually wrong

permalink
report
parent
reply
2 points
*

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” 😂

permalink
report
parent
reply
10 points
*

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

permalink
report
parent
reply
7 points

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

permalink
report
parent
reply
6 points

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

permalink
report
parent
reply
8 points

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

/S

permalink
report
parent
reply
3 points
*

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

Edit: Sorry didn’t see /S

permalink
report
parent
reply
5 points

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

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

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

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 7.4K

    Monthly active users

  • 761

    Posts

  • 12K

    Comments