News for hackers. Stuff that matters.
Re:OpenBSD now enforcing no invalid NUL characters in shell ... by bityard on Tuesday September 24, 2024 @10:40AM (#41636972)
Well, knowing how to deal with wacky input and corner cases are a requirement of learning ANY programming language. Bourne-style shells are no exception.

Your example has illegal syntax, but the biggest issue is that you should never parse the output of ls. The shell has built-in globbing. This is how you would loop over all entries (files, dirs, symlinks, etc) in the current directory without getting tripped up by whitespace:

    for e in *; do echo "got: $e"; done
Re:OpenBSD now enforcing no invalid NUL characters in shell ... by Taikonerd on Tuesday September 24, 2024 @10:46AM (#41637060)
> knowing how to deal with wacky input and corner cases are a requirement of learning ANY programming language.

In general, I agree. But if there's a corner case that occasionally breaks naive code but otherwise doesn't do anything, then I'm going to think, "maybe we should just remove that corner case."

Re:OpenBSD now enforcing no invalid NUL characters in shell ... by zokier on Tuesday September 24, 2024 @11:55AM (#41637927)
David Wheeler has been complaining (and suggesting fixes) about this for a long time: https://dwheeler.com/essays/fixing-unix-linux-filenames.html

safename LSM https://lwn.net/Articles/686789/

Re:OpenBSD now enforcing no invalid NUL characters in shell ... by Taikonerd on Tuesday September 24, 2024 @01:44PM (#41639059)
Thank you, I had wondered if there was something like safename.
Re:OpenBSD now enforcing no invalid NUL characters in shell ... by bell-cot on Tuesday September 24, 2024 @11:00AM (#41637247)
Replace "maybe" with "OBVIOUSLY". Keeping useless-but-hazardous "features" in any language is as idiotic as keeping a heap of oily rags in the furniture factory warehouse.
Re:OpenBSD now enforcing no invalid NUL characters in shell ... by dzaima on Tuesday September 24, 2024 @09:38PM (#41642810)
But, of course, this wouldn't be shell if that didn't have footguns more; namely, it breaks if ran in an empty directory (giving a literal "got: *"), and excludes the arbitrary set of files whose name begins with ".".