6 ms·
> (1) everything is text And lists are space-separated. Unless you want them to be newline-separated, or NUL-separated, which is controlled by an option that m
by jcranmer 6y ago
> (1) everything is text
And lists are space-separated. Unless you want them to be newline-separated, or NUL-separated, which is controlled by an option that may or may not be present for the command you're invoking, and is spelled completely differently for each program. Or maybe you just quote spaces somehow, and good luck figuring out who is responsible for inserting quotes and who is responsible for removing them.
- chooseaname 6y agoAll of which are so much easier to deal with than some binary format you have no spec on. XML? SMH.
- 6gvONxR4sf7o 6y agoGod help you if your paths have spaces in them.
- gorgoiler 6y agoBy “God” you may mean “libc”... ...if it was the 1970s. Nowadays we use Python etc for tools where it’s less acceptable for them to fall apart, though everything falls apart at some point, spaces or otherwise.
- anthk 6y agoThat's Perl role, not Python. You are like 20 years late, kid. Have fun with that shitty whitespace syntax. At least Perl can be refactorized.
- bananabreakfast 6y agoDon't you mean Raku? lol
- naniwaduni 6y agoPerl 5 was more suitable for these particular use cases than perl 6 ever tried to be.
- anthk 6y agoPerl5 was and is amazing. Check the articles from https://linuxfocus.com https://linuxfocus.com and the old Linux Gazzete magazines from TLDP: https://linuxgazette.net/archives.html https://linuxgazette.net/archives.html.
- bityard 6y agoJust quote paths? shrug
- mehrdadn 6y agoTry doing that in e.g. Make
- fao_ 6y agoTry finding out which registry key you need to edit to get something to happen. Some things across different systems have pitfalls as a result of their implementation, or some features have pitfalls. There are half a dozen things I can point to on windows that are worse than the "spaces in filenames". Hell, windows doesn't even support ISO 8601 dates, or times to be properly placed in files. It restricts symbols much more than Linux / Unix
- yzmtf2008 6y agowho said anything about windows?
- fao_ 6y agoThe parent thread referenced windows as something that handles spaces in filenames. I'm not sure why I'm getting downvoted when my comment was relevant to the debate occurring, and my point (that all features have downfalls caused by the necessity of implementation within the surrounding system, and in the case of command line arguments, linguistics and common keyboards themselves) is something that according to the guidelines should be debated against, not downvoted.
- yzmtf2008 6y agoNone of the parents of your comment mentioned Windows. Perhaps you have the wrong thread?
- blacksqr 6y ago
- deleted 6y ago[deleted]
- mfontani 6y agoNo need to invoke a deity to do that... echo 'Hi!' | tee "$(printf "foo\nbar\tqu ux.txt")" cat foo$'\n'bar$'\t'qu' 'ux.txt IIRC the latter only works in ksh93+, but the former should be fine pretty much in any shell.
- JdeBP 6y ago... except if one uses \c by mistake. \c has unspecified behaviour, and is one of the things that varies widely from one implementation of printf to another. * https://unix.stackexchange.com/a/558665/5132 https://unix.stackexchange.com/a/558665/5132
- hnlmorg 6y agoThat's a POSIX shell thing rather than a Unix pipeline thing. Some non-POSIX shells don't have this problem while still passing data long Unix pipes Source: I wrote a shell and it solves a great many of the space / quoting problems with POSIX shells.
- buzzkillington 6y agoSame, I've built toy shells [0] that used xml, s-expressions and ascii delimited text [1]. The last was closest to what unix pipes should be like. Of course it breaks ALL posix tools, but it felt like a shell that finally works as you'd expect it to work. [0] Really just input + exec + pipes. [1] https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
- JdeBP 6y agoHere's one tool that it does not break. (-: * http://jdebp.uk./Softwares/nosh/guide/commands/console-flat-table-viewer.xml http://jdebp.uk./Softwares/nosh/guide/commands/console-flat-...
- hnlmorg 6y agoAs long as you re-serialise that data when piping to coreutils (etc) you shouldn't have an issue. This is what my shell (https://github.com/lmorg/murex https://github.com/lmorg/murex) does. It defaults to using JSON as a serialisation format (that's how arrays, maps, etc are stored, how spaces are escaped, etc) but it can re-serialise that data when piping into executables which aren't JSON aware. Other serialisation formats are also supported such as YAML, CSV and S-Expressions too. I had also considered adding support for ASCII records but it's not a use case I personally run into (unlike JSON, YAML, CSV, etc) so haven't written a marshaller to support it yet.
- buzzkillington 6y agoAscii records have worked better than json, xml, s-expressions (better as in provide the same bang for a lot less buck) in every case I've used them for. I have no idea why I am the only person I know who uses them regularly.
- gorgoiler 6y agoTo criticize sh semantics without acknowledging that C was always there when you needed something serious is a bit short sighted. There are two uses of the Unix “api”: [A] Long lived tools for other people to use. [B] Short lived tools one throws together oneself. The fact that most things work most of the time is why the shell works so well for B, and why it is indeed a poor choice for the sort of stable tools designed for others to use, in A. The ubiquity of the C APIs of course solved [A] use cases in the past, when it was unconscionable to operate a system without cc(1). It’s part of why they get first class treatment in the Unix man pages, as old fashioned as that seems nowadays.
- jcranmer 6y agoThere's a certain irony in responding to criticism of that which you're extolling by saying not to use it. And the only reason I might be pushed down that path is because the task I'm working on happens to involve filenames with spaces in them (without those spaces, the code would work fine!), because spaces are a reasonable thing to put in a filename unless you're on a Unix system.
- coliveira 6y agoThe shell works with spaces, you just need to be careful to quote every file name. The advantage of using file names without spaces is that you can avoid the quotes.
- viraptor 6y agoPlease don't ever assume you can avoid spaces and quotes. It's just a time bomb. It's like people saying you don't need to escape SQL values because they come from constants. Yes, they do... today. It's not just quoting either. It's setting the separator value and reverting it correctly. It's making sure you're still correct when you're in a function in an undefined state. It's a lot of overhead in larger projects.
- CountSessine 6y ago
- gricardo99 6y ago>good luck figuring out ... luck, or simply execute the steps you want to check by typing them on the command line. I find the pipes approach incredibly powerful and simple because you can compose and check each step, and assemble. That's really the point, and the power, of a simple and extensible approach.
- derefr 6y agoPeople struggle so much with this, but I don't see what the point is at all. The fundamental problem that playing with delimiters solves, is passing arbitrary strings through as single tokens. Well, that's easy. Don't escape or quote the strings; encode them. Turn them into opaque tokens, and then do Unix things to the opaque tokens, before finally decoding them back to being strings. There's a reason od(1) is in coreutils. It's a Unix fundamental when working with arbitrary data. Hex and base64 are your friends (and Unix tools are happy to deal with both.)
- brokenmachine 6y agoNever heard about this, would this affect performance? Can you give some examples?
- fomine3 6y agoThe fact that filename can contain anything except NULL/slash is really pain. I often write a shell script that treats LF as separator but I know it's not good.
- enriquto 6y agofilenames are variable names. Choosing good filenames is the first step in writing a nice shell script in a situation that you control.
- brokenmachine 6y agoWhy not use null as a separator? I agree it's messy but not that hard. Just set IFS to null.
- jlg23 6y agoOr you just pipe through the program of your choice for which you know the syntax: echo "foo bar fnord" | cut --delimiter " " --output-delimiter ":" -f1- # foo:bar:fnord
- bloopernova 6y agoI love learning new things about commands I've used for years. --output-delimiter ":" Very cool! However it does require the GNU version of cut, not the Mac OS X supplied BSD version. In zsh at least, you can do: alias cut='/usr/local/bin/gcut'
- michaelcampbell 6y agoAh yes, perfect is the enemy of the good.
- pwdisswordfish2 6y agoWorks for me.
- ComputerGuru 6y agoI think this was a failure on behalf of early terminal emulator developers. End-of-field and end-of-record should have been supported by the tty (either as visual symbols or via some sort of physical distancing, etc even if portrayed just as a space and a new line respectively) so that the semantic definition could have been preserved/distinguished.
- junon 6y agoTTYs in general are some of the most outdated and archiac pieces of technology still used today. They need a serious overhaul, but the problem is, any major change will break pretty much all programs.