top | item 46432020

(no title)

diarrhea | 2 months ago

No thank you...

One of the primary things shells are supposed to excel at is file system navigation and manipulation, but the experience is horrible. I can never get `cp`, `rsync`, `mv`, `find` right without looking them up, despite trying to learn. It's way too easy to mess up irreversibly and destructively.

One example is flattening a directory. You accidentally git-cloned one too deep, into `some/dir/dir/` and want to flatten contents to `some/dir/`, deleting the then-empty `some/dir/dir/`. Trivial and reversible in any file manager, needlessly difficult in a shell. I get it wrong all the time.

Similarly, iterating over a list of files (important yet trivial). `find` is arcane in its invocation, differs between Unix flavors, you will want `xargs` but `{}` substitution is also very error-prone. And don't forget `print0`! And don't you even dare `for f in *.pdf`, it will blow up in more ways than you can count. Also prepare to juggle quotes and escapes and pray you get that right. Further, bash defaults are insane (pray you don't forget `set -euo pipefail`).

How can we be failed by our tools so much, for these use cases? Why aren't these things trivial and safe?

discuss

order

monooso|2 months ago

I agree that certain commands require some effort to learn, but I would not include `cp` or `mv` in that list.

diarrhea|2 months ago

I have trouble gauging the effects of `*`, aka "will I cp/mv the dir or all contents of the dir"? Then shell expansion getting in the way, like expanding it all ("argument list too long"). I try to use rsync when possible, where intermittent `.` in paths are relevant, as well as trailing slashes... and don't forget `-a`! Then I forget if those same things apply to cp/mv. Then I cp one directory too deep and need to undo the mess -- no CTRL+Z!

The wide-spread use of `rm -rf some-ostensibly-empty-dir/` is also super dangerous, when `rm -r` or even `rmdir` would suffice, but you need to remember those exist. I find it strange there's no widely (where applicable) available `rm-to-trash`, which would be wildly safer and is table stakes for Desktop work otherwise.

Then there's `dd`...

I use terminals a lot, but a GUI approach (potentially with feedback pre-operation) plus undo/redo functionality for file system work is just so much easier to work with. As dumb as drag-and-drop with a mouse is, a single typo can't wreck your day.

donkeybeer|2 months ago

What is there to get wrong in your flattening dir example? I'd mv the internal dir as some other name to outside say dir2, them rm rf outer and mv the dir2. Unless there is something wrong in this approach.

I would agree with the rest, I always have to look up find and xargs syntax.

20k|2 months ago

If you make a typo, it'll go wrong. This is something that file managers fundamentally do not suffer from when trying to do that operation

greatgib|2 months ago

   can never get `cp`, `rsync`, `mv`, `find` right without looking them up
Wow! You have the brain really fried by not using it if you have issue using these simple command without help.

I would double down on advising you to go back learning to use the roots before getting IDE or llm assistant...

diarrhea|1 month ago

Interesting attack on my person!

The things I want to get done on my computer are so much richer than moving files back and forth in a terminal all day. Simple things should be simple. Tools should enable us. Moving files is a means to an end and these commands having so many sharp edges makes me unhappy indeed.

But yes, of course I am an IDE toddler and cannot even tie my shoes without help from an LLM, thanks for reminding me.

abhinai|2 months ago

Most of the commands you've mentioned have worked fairly well for me. Are you sure you're looking up cp, mv and find every time before using them? Sounds pretty weird.

xigoi|2 months ago

With fish, `for f in *.pdf` Just Works™.

FeloniousHam|2 months ago

This is also a crutch. Take the time to learn the kludgier tool. It will make you a better developer.

/s (I'm a big fan of fish)

eddyg|2 months ago

Same with zsh

000ooo000|2 months ago

mv --interactive

cp --interactive

rm --interactive

alecco|2 months ago

LLMs make all those commands trivial to learn. Back in the day we had to study whole man pages meant as reference. Like keeping attention for minutes at a time. The horror!

morkalork|2 months ago

You read the manpages once and then if you're some super elite user you create some aliases for yourself.

Or if you are me, you do `history | grep name-of-command` to find the last time you used it and edit that haha