this post was submitted on 03 May 2024
14 points (64.6% liked)
Linux
48193 readers
1305 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Zsh has some important differences in how it handles whitespace and quoting, which affects OP's exact example.
Consider this:
In zsh, this works. In bash, it will give you six errors saying d, e, f, g, h, and i do not exist.
fxd
That will work in either zsh or bash, yes. It's a good habit to use quotes, but I am pointing out that quoting and expansion behavior is not the same across all shells.
It's the same across all POSIX compliant shells.
zsh
is not POSIX compliant.That only affects whitespaces within quotes though. Still, fair point, except I just tried a bunch of stuff in both bash and zsh and touching a file works, echoing a string works, then I stopped so I don't know about the asterisk but we have already veered far away from what OP said: "normal foor (sic) loop with whitespace in file names" - whereas what you had seems significantly more advanced than a "normal" foor (sic:-P) loop.
Notably, Mac OSX right out of the box uses zsh. I haven't touched "standard" personal distros for a number of years but a quick search suggests that Mint, Ubuntu, and NixOS all use bash by default - which halfway though not entirely surprises me? Anyway if OP wants to change their default shell to something more advanced, that would be fine for common every-day usage, though asking for bash itself to now be changed after decades of backwards compatibility seems a non-starter to me. There are reasons for why it works as it does, and those reasons have nothing to do with it being "old", but rather b/c it "works".
And the underlying reason for that is b/c we are still using keyboards. The addition of mice as HUDs enabled drag-and-drop, and perhaps some kind of glove or fingertip reader or eyesight-tracker may allow the same, like Minority Report (an old movie) or Iron Man style pinching an "object", grabbing it and letting it go, is basically just another style of "mouse". Afaik, there hasn't been even a hint of anything truly revolutionary for all this time. Although I can envision one such idea: combining keyboard+"mouse" in a more intelligent way, like if you start typing a command, then fix your eyes on the screen to a particular file and perhaps flick your eyes in a particular direction to indicate acceptance and it could fill it in for you, without having to move your hands away from the keyboard. With glasses and ubiquitous cameras everywhere now, we might see something like that in a few decades? Though it would put further pressure onto privacy concerns over having a camera watching every move you make.
With Debian-based distros, it's actually a bit weirder. They use
dash
as the global default shell (i.e. for executingsh
scripts).dash
has basically no code for interactive use, so it's supposedly faster and more secure. It is POSIX-compliant, so the treatment of whitespace should be identical, but it doesn't support any of the added features ofbash
.If you open up a terminal emulator, they've got that set up to use
bash
by default, sodash
is supposed to be invisible to the user, but well, spoilers, it's not. If you switch to a TTY, for example, it launches there and makes the TTY look completely broken.Hehe thank you for the fun extra story:-).
Yeah, Apple moved to Zsh as default some years back, which is the main reason I'm familiar with its differences in terms of parameter expansion. They still ship Bash 3.2 with macOS, but they can't ship newer versions due to GPLv3 licensing, or something like that. So they had the motivation to switch.
In the Linux world, there's no great motivation to change the default, because Bash 5.x is already comparable to zsh in terms of features, and it's what everyone is already familiar with.
Perhaps I misunderstood OP's question. I figured they meant using variables. Otherwise I don't know how to make sense of it.
Admittedly, I too am not certain why "noone inprove bash such that you can write a normal foor loop with whitespace in file names?" :-P I just noticed that not only was "foor" loop misspelled, and "noone" is likewise improper (should be "no one" or "nobody"), but "inprove" is also a "performance improvement company that helps clients implement their internal continuous improvement programs more effectively, and achieve better, more consistent and sustained results", according to Google's (SEO) search feature:-P
Therefore, I have little trouble believing that they wanted all of bash to be changed - for free ofc - so that they could do something like:
And the computer would auto-magically figure out that since mv is a command involving files, and "Iron Man" is a file that exists, that it should be the first argument and the rest of the text is the second argument. i.e., why learn how bash works, when you can make a post to !Linux@lemmy.ml and put hundreds of programmers to work for you to change the entire world, at your beck and call, while also working in how ashamed they should be that they haven't done that effort preemptively?
Which ngl, might be a good idea. Or, you know, OP could learn to use tab-complete that already does that. I should have mentioned that I suppose... but it seems too late now b/c I doubt the mods will let this post remain for too much longer. Even if you were correct and they meant variables: they never actually said that, which makes this communication really difficult to both guess what OP might have meant and also solve their problem for them, on top of them being willing to learn on their own. But we can do better on our end too: perhaps we could create a community specialized in providing help to newcomers who want to learn linux - like what resources can they read/watch/play with, to help them get started? To be clear, *I'm* not offering to start that!!