Skip to main content
10 events
when toggle format what by license comment
Jul 11, 2014 at 11:50 comment added mikeserv @terdon - what hoops? It parses itself. You only have to configure it with variables. And this isn't either of our answers - this is an answer where you - probably rightly - corrected the poster about possible characters in filenames, but you also justified it with a link that makes no sense and is really very wrong - even the author justifies the problems he notes about ls with since I don't know of any ls implementation that allows you to delimit filenames with NUL bytes... though you know otherwise from personal experience.
Jul 11, 2014 at 11:30 comment added terdon @mikeserv let's not start this all over again. Yes, that is two lines and yes it is possible to parse ls safely if you want to jump through hoops. However, that is not what the OP here is doing and what the OP is doing fails for all sorts of reasons, including problems with parsing ls. Note that I did not whine about ls in your answer since you were doing something very different.
Jul 11, 2014 at 11:24 comment added mikeserv @terdon - ls isn't going to eat your children or anything - it's only a program. If you don't explain it then it will take several hundred to explain it and several hundred more to explain why the several hundred lines you just linked to are wrong. And besides - this is only two lines: LS_COLORS='lc=:rc=:ec=:ln=\n\n\0HERE_THERE_BE_A_LINK>>\0:' \ ls -1 --color=always | cat
Jul 11, 2014 at 9:30 comment added terdon @mikeserv I know, I know. However, explaining how to do this safely takes several hundred lines as you yourself have demonstrated. As it stands, this answer suffers from all the dangers of parsing ls and the OP is clearly not aware of them.
Jul 10, 2014 at 21:51 comment added mikeserv @terdon - ls parses itself. we all parse ls every time we print to a terminal - there's an api. I posted an answer demonstrating something like it here - but you can do a lot more. I showed you just the other day - you had null-delimited filenames yourself.
Jul 10, 2014 at 21:01 comment added Gilles 'SO- stop being evil' @terdon There are more fundamental reasons why this will fail. Either ls is aliased to ls -l, and this returns columns before the file name, or it isn't, and this doesn't do anything special about symbolic links.
Jul 9, 2014 at 11:30 comment added terdon That will fail for various reasons, for example on a file called a -> b. It will also fail on file names with newlines and other strangeness. Please read this for why parsing ls is a bad idea.
Jul 9, 2014 at 11:21 history edited polym CC BY-SA 3.0
edited body
Jul 9, 2014 at 11:13 review Low quality posts
Jul 9, 2014 at 11:21
Jul 9, 2014 at 10:55 history answered csny CC BY-SA 3.0