News for hackers. Stuff that matters.
Re:Become Shell Literate by Aloha on Saturday December 12, 2020 @01:07PM (#25400170)
It wouldn't be coherently unixy if it was. Small tools that do a limited subset of things, and reliably take/output data from stdin/stdout is the way unix is done. sh is just the glue we use to tack it all together.

Bash (and other shells too) is like it is, because it's an accretion of 50 years of history rather than a singular top down design.

Re:Become Shell Literate by cle on Saturday December 12, 2020 @01:48PM (#25400464)
I think a misunderstood part of Emacs is that this is exactly what it is—-it’s just glue, but instead of being in a command-oriented environment, it’s in an editor-oriented environment. You run the same Unix tools but glue their results together into a text buffer with a full programming language that then lets you programmatically edit the results.

People joke about Emacs being an OS but it’s really just a different kind of shell, oriented towards text editing instead of issuing commands.

Re:Become Shell Literate by Aloha on Sunday December 13, 2020 @01:39AM (#25404781)
Without commenting on substance, Emacs is an application that rehomed itself on unix, but isnt a genetic unix application, Emacs was developed on ITS.
Re:Become Shell Literate by randomswede on Monday December 14, 2020 @11:08AM (#25419116)
Definitely originally. I suspect that a modern emacs has more unix under the hood than it has ITS under the hood.

I am not sure if we should care about the differentiation between TECO-Emacs on one hand and Elisp-Emacs on the other.

Re:Become Shell Literate by CJefferson on Saturday December 12, 2020 @01:13PM (#25400213)
One of the best things (in my opinion) shells could have done is do newline separated filenames instead of spaces, which would make filenames with spaces much easier to handle (you can have newlines in filenames, but in this magic world let's ban those).
Re:Become Shell Literate by chubot on Saturday December 12, 2020 @02:05PM (#25400581)
Oil fixes this problem with QSN: http://www.oilshell.org/blog/2020/10/osh-features.html#safe-...

You can have newlines in filenames, but you can also pass binary data with \0 if you want (it's 8 bit clean). Or you can use read -0 for a NUL delimiter, and eventually length-prefixed blobs with netstrings.

The way I now think of it is that Oil should have all 3 solutions to "the framing problem" in networking: delimiting, escaping, and length prefixing. So you can convert from one regime to the other by using shell.

Re:Become Shell Literate by enriquto on Saturday December 12, 2020 @01:15PM (#25400229)
That would pose problems also. The real solution, with no need to magic as you say, is to disallow spaces at the filesystem level (just like slashes and the null character are forbidden). For users typing filenames, this shouldn't be a problem, as those can be encoded e.g., as unicode's non-breaking space. Using space as a separator is a very important power, that other programming languages share. In what other programming language can you put spaces in variable names? In the shell, filenames are variable names! It is only natural that a space cannot appear inside a filename (but of course, most other unicode characters can).
Re:Become Shell Literate by jodrellblank on Saturday December 12, 2020 @01:32PM (#25400339)
> In what other programming language can you put spaces in variable names?

PowerShell; although you have to use long form to do it:

    PS C:\> ${var with spaces} = 1

    PS C:\> Get-Variable *space*

    Name                           Value                                                                                                       
    ----                           -----                                                                                                       
    var with spaces                1                                                                                                           



    PS C:\> ${var with spaces} + 2
    3
Re:Become Shell Literate by layer8 on Saturday December 12, 2020 @01:37PM (#25400385)
> In what other programming language can you put spaces in variable names?

In SQL, notably. Such identifiers need to be quoted, of course.

Re:Become Shell Literate by dragonwriter on Saturday December 12, 2020 @02:57PM (#25401082)
> In what other programming language can you put spaces in variable names?

ISTR that many dynamic languages allow this with dynamic assignment features, but you often need to use similar dynamic access functiona rather than simple variable access to access them.

Ruby also allows whitespace if it is unicode but not ASCII whitespace, without use of dynamic assignment/access methods.

SQL allows spaces in object names but requires quoting, similar to shell.

Re:Become Shell Literate by CJefferson on Saturday December 12, 2020 @01:25PM (#25400299)
This would require filenames became valid utf-8. This would be a good thing to do nowadays, irritatingly (having tried handling Unix filenames as utf 8 in the past), surprisingly many users have non-utf8 filenames.
Re:Become Shell Literate by a1369209993 on Saturday December 12, 2020 @07:48PM (#25403263)
> This would require filenames became valid utf-8.

No, it wouldn't; you'd just get EINVAL if you pass a filename containing "\x20" to open or other syscalls. If a application wants to use "\xC2\xA0" in a filename, it can do that, or it can not do that, same as currently. Same applies if it wants to use, say, "\xAA\xFF".

Re:Become Shell Literate by Serow225 on Saturday December 12, 2020 @08:41PM (#25403534)
You can have spaces in F# variable names and functions :)
Re:Become Shell Literate by dafoex on Saturday December 12, 2020 @01:46PM (#25400445)
I totally agree that file names shouldn't have spaces because they are variables, and I (usually) name all my files with camelBackNotation names as I was taught is best practice for variable names. That said, with every command I remember running, treating the file name like a string - e.g. "file name.png" - has worked whenever I encounter spaces, no escape characters required.
Re:Become Shell Literate by CJefferson on Saturday December 12, 2020 @02:48PM (#25401005)
The problem is shell is when I want to write something like 'find . | grep namepiece | xargs rm', or something like that. I can work around this by piling everything into the find, or in some cases by liberally spreading -0s around, but neither feel very "shell-like" to me.
Re:Become Shell Literate by enriquto on Saturday December 12, 2020 @03:27PM (#25401390)
Thus it seems that a filesystem that forbade spaces in its filenames would solve your problems with the shell? Sounds good to me!
Re:Become Shell Literate by lock-free on Saturday December 12, 2020 @01:35PM (#25400356)
I don't see a functional difference in denying spaces in paths from denying new lines in paths.

My dream OS would forbid path names that don't match \w in grep.